diff --git a/CHANGELOG.md b/CHANGELOG.md index 7785f5672c..f62aff853b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,20 +4,35 @@ [1]: https://pypi.org/project/google-cloud-spanner/#history +## [1.15.0](https://www.github.com/googleapis/python-spanner/compare/v1.14.0...v1.15.0) (2020-03-17) + + +### Features + +* Add emulator support ([#14](https://www.github.com/googleapis/python-spanner/issues/14)) ([b315593](https://www.github.com/googleapis/python-spanner/commit/b315593bd3e473d96cc3033f5bbf0da7487e38eb)) +* Export transaction._rolled_back as transaction.rolled_back ([#16](https://www.github.com/googleapis/python-spanner/issues/16)) ([974ee92](https://www.github.com/googleapis/python-spanner/commit/974ee925df1962f559d6cb43318ee301e330e8f2)) +* Add support for backups ([#35](https://www.github.com/googleapis/python-spanner/issues/35)) ([39288e7](https://www.github.com/googleapis/python-spanner/commit/39288e784826c5accca71096be11f99ad7f930f4)) +* Implement query options versioning support ([#30](https://www.github.com/googleapis/python-spanner/issues/30)) ([5147921](https://www.github.com/googleapis/python-spanner/commit/514792151c2fe4fc7a6cf4ad0dd141c9090a634b)) + + +### Bug Fixes + +* Remove erroneous timeouts for batch_create_session calls ([#18](https://www.github.com/googleapis/python-spanner/issues/18)) ([997a034](https://www.github.com/googleapis/python-spanner/commit/997a03477b07ec39c718480d9bfe729404bf5748)) + ## [1.14.0](https://www.github.com/googleapis/python-spanner/compare/v1.13.0...v1.14.0) (2020-01-31) ### Features -* **spanner:** add deprecation warnings; add field_mask to get_instance; add endpoint_uris to Instance proto; update timeouts; make mutations optional for commits (via synth) ([62edbe1](https://www.github.com/googleapis/python-spanner/commit/62edbe12a0c5a74eacb8d87ca265a19e6d27f890)) -* **spanner:** add resource based routing implementation ([#10183](https://www.github.com/googleapis/python-spanner/issues/10183)) ([e072d5d](https://www.github.com/googleapis/python-spanner/commit/e072d5dd04d58fff7f62ce19ce42e906dfd11012)) -* **spanner:** un-deprecate resource name helper functions, add 3.8 tests (via synth) ([#10062](https://www.github.com/googleapis/python-spanner/issues/10062)) ([dbb79b0](https://www.github.com/googleapis/python-spanner/commit/dbb79b0d8b0c79f6ed1772f28e4eedb9d986b108)) +* Add deprecation warnings; add field_mask to get_instance; add endpoint_uris to Instance proto; update timeouts; make mutations optional for commits (via synth) ([62edbe1](https://www.github.com/googleapis/python-spanner/commit/62edbe12a0c5a74eacb8d87ca265a19e6d27f890)) +* Add resource based routing implementation ([#10183](https://www.github.com/googleapis/google-cloud-python/issues/10183)) ([e072d5d](https://www.github.com/googleapis/python-spanner/commit/e072d5dd04d58fff7f62ce19ce42e906dfd11012)) +* Un-deprecate resource name helper functions, add 3.8 tests (via synth) ([#10062](https://www.github.com/googleapis/google-cloud-python/issues/10062)) ([dbb79b0](https://www.github.com/googleapis/python-spanner/commit/dbb79b0d8b0c79f6ed1772f28e4eedb9d986b108)) ### Bug Fixes -* be permssive about merging an empty struct ([#10079](https://www.github.com/googleapis/python-spanner/issues/10079)) ([cfae63d](https://www.github.com/googleapis/python-spanner/commit/cfae63d5a8b8332f8875307283da6075a544c838)) -* **spanner:** fix imports for doc samples ([#10283](https://www.github.com/googleapis/python-spanner/issues/10283)) ([55a21d9](https://www.github.com/googleapis/python-spanner/commit/55a21d97d0c863cbbbb2d973b6faa4aeba8e38bb)) +* Be permssive about merging an empty struct ([#10079](https://www.github.com/googleapis/google-cloud-python/issues/10079)) ([cfae63d](https://www.github.com/googleapis/python-spanner/commit/cfae63d5a8b8332f8875307283da6075a544c838)) +* Fix imports for doc samples ([#10283](https://www.github.com/googleapis/google-cloud-python/issues/10283)) ([55a21d9](https://www.github.com/googleapis/python-spanner/commit/55a21d97d0c863cbbbb2d973b6faa4aeba8e38bb)) ## 1.13.0 diff --git a/google/cloud/spanner_admin_database_v1/gapic/database_admin_client.py b/google/cloud/spanner_admin_database_v1/gapic/database_admin_client.py index cbb2c084cd..38f16638bd 100644 --- a/google/cloud/spanner_admin_database_v1/gapic/database_admin_client.py +++ b/google/cloud/spanner_admin_database_v1/gapic/database_admin_client.py @@ -31,6 +31,7 @@ import google.api_core.operations_v1 import google.api_core.page_iterator import google.api_core.path_template +import google.api_core.protobuf_helpers import grpc from google.cloud.spanner_admin_database_v1.gapic import database_admin_client_config @@ -38,6 +39,7 @@ from google.cloud.spanner_admin_database_v1.gapic.transports import ( database_admin_grpc_transport, ) +from google.cloud.spanner_admin_database_v1.proto import backup_pb2 from google.cloud.spanner_admin_database_v1.proto import spanner_database_admin_pb2 from google.cloud.spanner_admin_database_v1.proto import spanner_database_admin_pb2_grpc from google.iam.v1 import iam_policy_pb2 @@ -45,6 +47,7 @@ from google.iam.v1 import policy_pb2 from google.longrunning import operations_pb2 from google.protobuf import empty_pb2 +from google.protobuf import field_mask_pb2 _GAPIC_LIBRARY_VERSION = pkg_resources.get_distribution("google-cloud-spanner").version @@ -56,7 +59,8 @@ class DatabaseAdminClient(object): 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. + databases. It can be also used to create, delete and list backups for a + database and to restore from an existing backup. """ SERVICE_ADDRESS = "spanner.googleapis.com:443" @@ -86,6 +90,16 @@ def from_service_account_file(cls, filename, *args, **kwargs): from_service_account_json = from_service_account_file + @classmethod + def backup_path(cls, project, instance, backup): + """Return a fully-qualified backup string.""" + return google.api_core.path_template.expand( + "projects/{project}/instances/{instance}/backups/{backup}", + project=project, + instance=instance, + backup=backup, + ) + @classmethod def database_path(cls, project, instance, database): """Return a fully-qualified database string.""" @@ -264,7 +278,7 @@ def create_database( ``[a-z][a-z0-9_\-]*[a-z0-9]`` and be between 2 and 30 characters in length. If the database ID is a reserved word or if it contains a hyphen, the database ID must be enclosed in backticks (`````). - extra_statements (list[str]): An optional list of DDL statements to run inside the newly created + extra_statements (list[str]): Optional. A list of DDL statements to run inside the newly created database. Statements can create tables, indexes, etc. These statements execute atomically with the creation of the database: if there is an error in any statement, the database is not created. @@ -516,7 +530,8 @@ def drop_database( metadata=None, ): """ - Drops (aka deletes) a Cloud Spanner database. + Drops (aka deletes) a Cloud Spanner database. Completed backups for the + database will be retained according to their ``expire_time``. Example: >>> from google.cloud import spanner_admin_database_v1 @@ -654,11 +669,12 @@ def set_iam_policy( metadata=None, ): """ - Sets the access control policy on a database resource. Replaces any - existing policy. + Sets the access control policy on a database or backup resource. + Replaces any existing policy. Authorization requires ``spanner.databases.setIamPolicy`` permission on - ``resource``. + ``resource``. For backups, authorization requires + ``spanner.backups.setIamPolicy`` permission on ``resource``. Example: >>> from google.cloud import spanner_admin_database_v1 @@ -740,11 +756,13 @@ def get_iam_policy( metadata=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. + Gets the access control policy for a database or backup resource. + Returns an empty policy if a database or backup exists but does not have + a policy set. Authorization requires ``spanner.databases.getIamPolicy`` permission on - ``resource``. + ``resource``. For backups, authorization requires + ``spanner.backups.getIamPolicy`` permission on ``resource``. Example: >>> from google.cloud import spanner_admin_database_v1 @@ -823,13 +841,15 @@ def test_iam_permissions( metadata=None, ): """ - Returns permissions that the caller has on the specified database - resource. + Returns permissions that the caller has on the specified database or + backup resource. Attempting this RPC on a non-existent Cloud Spanner database will result in a NOT\_FOUND error if the user has ``spanner.databases.list`` permission on the containing Cloud Spanner instance. Otherwise returns - an empty set of permissions. + an empty set of permissions. Calling this method on a backup that does + not exist will result in a NOT\_FOUND error if the user has + ``spanner.backups.list`` permission on the containing instance. Example: >>> from google.cloud import spanner_admin_database_v1 @@ -901,6 +921,903 @@ def test_iam_permissions( request, retry=retry, timeout=timeout, metadata=metadata ) + def create_backup( + self, + parent, + backup_id, + backup, + retry=google.api_core.gapic_v1.method.DEFAULT, + timeout=google.api_core.gapic_v1.method.DEFAULT, + metadata=None, + ): + """ + Starts creating a new Cloud Spanner Backup. The returned backup + ``long-running operation`` will have a name of the format + ``projects//instances//backups//operations/`` + and can be used to track creation of the backup. The ``metadata`` field + type is ``CreateBackupMetadata``. The ``response`` field type is + ``Backup``, if successful. Cancelling the returned operation will stop + the creation and delete the backup. There can be only one pending backup + creation per database. Backup creation of different databases can run + concurrently. + + Example: + >>> from google.cloud import spanner_admin_database_v1 + >>> + >>> client = spanner_admin_database_v1.DatabaseAdminClient() + >>> + >>> parent = client.instance_path('[PROJECT]', '[INSTANCE]') + >>> + >>> # TODO: Initialize `backup_id`: + >>> backup_id = '' + >>> + >>> # TODO: Initialize `backup`: + >>> backup = {} + >>> + >>> response = client.create_backup(parent, backup_id, backup) + >>> + >>> def callback(operation_future): + ... # Handle result. + ... result = operation_future.result() + >>> + >>> response.add_done_callback(callback) + >>> + >>> # Handle metadata. + >>> metadata = response.metadata() + + Args: + parent (str): Required. The name of the instance in which the backup will be created. + This must be the same instance that contains the database the backup + will be created from. The backup will be stored in the location(s) + specified in the instance configuration of this instance. Values are of + the form ``projects//instances/``. + backup_id (str): Required. The id of the backup to be created. The ``backup_id`` appended + to ``parent`` forms the full backup name of the form + ``projects//instances//backups/``. + backup (Union[dict, ~google.cloud.spanner_admin_database_v1.types.Backup]): Required. The backup to create. + + If a dict is provided, it must be of the same form as the protobuf + message :class:`~google.cloud.spanner_admin_database_v1.types.Backup` + retry (Optional[google.api_core.retry.Retry]): A retry object used + to retry requests. If ``None`` is specified, requests will + be retried using a default configuration. + timeout (Optional[float]): The amount of time, in seconds, to wait + for the request to complete. Note that if ``retry`` is + specified, the timeout applies to each individual attempt. + metadata (Optional[Sequence[Tuple[str, str]]]): Additional metadata + that is provided to the method. + + Returns: + A :class:`~google.cloud.spanner_admin_database_v1.types._OperationFuture` instance. + + Raises: + google.api_core.exceptions.GoogleAPICallError: If the request + failed for any reason. + google.api_core.exceptions.RetryError: If the request failed due + to a retryable error and retry attempts failed. + ValueError: If the parameters are invalid. + """ + # Wrap the transport method to add retry and timeout logic. + if "create_backup" not in self._inner_api_calls: + self._inner_api_calls[ + "create_backup" + ] = google.api_core.gapic_v1.method.wrap_method( + self.transport.create_backup, + default_retry=self._method_configs["CreateBackup"].retry, + default_timeout=self._method_configs["CreateBackup"].timeout, + client_info=self._client_info, + ) + + request = backup_pb2.CreateBackupRequest( + parent=parent, backup_id=backup_id, backup=backup + ) + if metadata is None: + metadata = [] + metadata = list(metadata) + try: + routing_header = [("parent", parent)] + except AttributeError: + pass + else: + routing_metadata = google.api_core.gapic_v1.routing_header.to_grpc_metadata( + routing_header + ) + metadata.append(routing_metadata) + + operation = self._inner_api_calls["create_backup"]( + request, retry=retry, timeout=timeout, metadata=metadata + ) + return google.api_core.operation.from_gapic( + operation, + self.transport._operations_client, + backup_pb2.Backup, + metadata_type=backup_pb2.CreateBackupMetadata, + ) + + def get_backup( + self, + name, + retry=google.api_core.gapic_v1.method.DEFAULT, + timeout=google.api_core.gapic_v1.method.DEFAULT, + metadata=None, + ): + """ + Gets metadata on a pending or completed ``Backup``. + + Example: + >>> from google.cloud import spanner_admin_database_v1 + >>> + >>> client = spanner_admin_database_v1.DatabaseAdminClient() + >>> + >>> name = client.backup_path('[PROJECT]', '[INSTANCE]', '[BACKUP]') + >>> + >>> response = client.get_backup(name) + + Args: + name (str): Required. Name of the backup. Values are of the form + ``projects//instances//backups/``. + retry (Optional[google.api_core.retry.Retry]): A retry object used + to retry requests. If ``None`` is specified, requests will + be retried using a default configuration. + timeout (Optional[float]): The amount of time, in seconds, to wait + for the request to complete. Note that if ``retry`` is + specified, the timeout applies to each individual attempt. + metadata (Optional[Sequence[Tuple[str, str]]]): Additional metadata + that is provided to the method. + + Returns: + A :class:`~google.cloud.spanner_admin_database_v1.types.Backup` instance. + + Raises: + google.api_core.exceptions.GoogleAPICallError: If the request + failed for any reason. + google.api_core.exceptions.RetryError: If the request failed due + to a retryable error and retry attempts failed. + ValueError: If the parameters are invalid. + """ + # Wrap the transport method to add retry and timeout logic. + if "get_backup" not in self._inner_api_calls: + self._inner_api_calls[ + "get_backup" + ] = google.api_core.gapic_v1.method.wrap_method( + self.transport.get_backup, + default_retry=self._method_configs["GetBackup"].retry, + default_timeout=self._method_configs["GetBackup"].timeout, + client_info=self._client_info, + ) + + request = backup_pb2.GetBackupRequest(name=name) + if metadata is None: + metadata = [] + metadata = list(metadata) + try: + routing_header = [("name", name)] + except AttributeError: + pass + else: + routing_metadata = google.api_core.gapic_v1.routing_header.to_grpc_metadata( + routing_header + ) + metadata.append(routing_metadata) + + return self._inner_api_calls["get_backup"]( + request, retry=retry, timeout=timeout, metadata=metadata + ) + + def update_backup( + self, + backup, + update_mask, + retry=google.api_core.gapic_v1.method.DEFAULT, + timeout=google.api_core.gapic_v1.method.DEFAULT, + metadata=None, + ): + """ + Updates a pending or completed ``Backup``. + + Example: + >>> from google.cloud import spanner_admin_database_v1 + >>> + >>> client = spanner_admin_database_v1.DatabaseAdminClient() + >>> + >>> # TODO: Initialize `backup`: + >>> backup = {} + >>> + >>> # TODO: Initialize `update_mask`: + >>> update_mask = {} + >>> + >>> response = client.update_backup(backup, update_mask) + + Args: + backup (Union[dict, ~google.cloud.spanner_admin_database_v1.types.Backup]): Required. The backup to update. ``backup.name``, and the fields to be + updated as specified by ``update_mask`` are required. Other fields are + ignored. Update is only supported for the following fields: + + - ``backup.expire_time``. + + If a dict is provided, it must be of the same form as the protobuf + message :class:`~google.cloud.spanner_admin_database_v1.types.Backup` + update_mask (Union[dict, ~google.cloud.spanner_admin_database_v1.types.FieldMask]): Required. A mask specifying which fields (e.g. ``expire_time``) in the + Backup resource should be updated. This mask is relative to the Backup + resource, not to the request message. The field mask must always be + specified; this prevents any future fields from being erased + accidentally by clients that do not know about them. + + If a dict is provided, it must be of the same form as the protobuf + message :class:`~google.cloud.spanner_admin_database_v1.types.FieldMask` + retry (Optional[google.api_core.retry.Retry]): A retry object used + to retry requests. If ``None`` is specified, requests will + be retried using a default configuration. + timeout (Optional[float]): The amount of time, in seconds, to wait + for the request to complete. Note that if ``retry`` is + specified, the timeout applies to each individual attempt. + metadata (Optional[Sequence[Tuple[str, str]]]): Additional metadata + that is provided to the method. + + Returns: + A :class:`~google.cloud.spanner_admin_database_v1.types.Backup` instance. + + Raises: + google.api_core.exceptions.GoogleAPICallError: If the request + failed for any reason. + google.api_core.exceptions.RetryError: If the request failed due + to a retryable error and retry attempts failed. + ValueError: If the parameters are invalid. + """ + # Wrap the transport method to add retry and timeout logic. + if "update_backup" not in self._inner_api_calls: + self._inner_api_calls[ + "update_backup" + ] = google.api_core.gapic_v1.method.wrap_method( + self.transport.update_backup, + default_retry=self._method_configs["UpdateBackup"].retry, + default_timeout=self._method_configs["UpdateBackup"].timeout, + client_info=self._client_info, + ) + + request = backup_pb2.UpdateBackupRequest(backup=backup, update_mask=update_mask) + if metadata is None: + metadata = [] + metadata = list(metadata) + try: + routing_header = [("backup.name", backup.name)] + except AttributeError: + pass + else: + routing_metadata = google.api_core.gapic_v1.routing_header.to_grpc_metadata( + routing_header + ) + metadata.append(routing_metadata) + + return self._inner_api_calls["update_backup"]( + request, retry=retry, timeout=timeout, metadata=metadata + ) + + def delete_backup( + self, + name, + retry=google.api_core.gapic_v1.method.DEFAULT, + timeout=google.api_core.gapic_v1.method.DEFAULT, + metadata=None, + ): + """ + Deletes a pending or completed ``Backup``. + + Example: + >>> from google.cloud import spanner_admin_database_v1 + >>> + >>> client = spanner_admin_database_v1.DatabaseAdminClient() + >>> + >>> name = client.backup_path('[PROJECT]', '[INSTANCE]', '[BACKUP]') + >>> + >>> client.delete_backup(name) + + Args: + name (str): Required. Name of the backup to delete. Values are of the form + ``projects//instances//backups/``. + retry (Optional[google.api_core.retry.Retry]): A retry object used + to retry requests. If ``None`` is specified, requests will + be retried using a default configuration. + timeout (Optional[float]): The amount of time, in seconds, to wait + for the request to complete. Note that if ``retry`` is + specified, the timeout applies to each individual attempt. + metadata (Optional[Sequence[Tuple[str, str]]]): Additional metadata + that is provided to the method. + + Raises: + google.api_core.exceptions.GoogleAPICallError: If the request + failed for any reason. + google.api_core.exceptions.RetryError: If the request failed due + to a retryable error and retry attempts failed. + ValueError: If the parameters are invalid. + """ + # Wrap the transport method to add retry and timeout logic. + if "delete_backup" not in self._inner_api_calls: + self._inner_api_calls[ + "delete_backup" + ] = google.api_core.gapic_v1.method.wrap_method( + self.transport.delete_backup, + default_retry=self._method_configs["DeleteBackup"].retry, + default_timeout=self._method_configs["DeleteBackup"].timeout, + client_info=self._client_info, + ) + + request = backup_pb2.DeleteBackupRequest(name=name) + if metadata is None: + metadata = [] + metadata = list(metadata) + try: + routing_header = [("name", name)] + except AttributeError: + pass + else: + routing_metadata = google.api_core.gapic_v1.routing_header.to_grpc_metadata( + routing_header + ) + metadata.append(routing_metadata) + + self._inner_api_calls["delete_backup"]( + request, retry=retry, timeout=timeout, metadata=metadata + ) + + def list_backups( + self, + parent, + filter_=None, + page_size=None, + retry=google.api_core.gapic_v1.method.DEFAULT, + timeout=google.api_core.gapic_v1.method.DEFAULT, + metadata=None, + ): + """ + Lists completed and pending backups. Backups returned are ordered by + ``create_time`` in descending order, starting from the most recent + ``create_time``. + + Example: + >>> from google.cloud import spanner_admin_database_v1 + >>> + >>> client = spanner_admin_database_v1.DatabaseAdminClient() + >>> + >>> parent = client.instance_path('[PROJECT]', '[INSTANCE]') + >>> + >>> # Iterate over all results + >>> for element in client.list_backups(parent): + ... # process element + ... pass + >>> + >>> + >>> # Alternatively: + >>> + >>> # Iterate over results one page at a time + >>> for page in client.list_backups(parent).pages: + ... for element in page: + ... # process element + ... pass + + Args: + parent (str): Required. The instance to list backups from. Values are of the form + ``projects//instances/``. + filter_ (str): An expression that filters the list of returned backups. + + A filter expression consists of a field name, a comparison operator, and + a value for filtering. The value must be a string, a number, or a + boolean. The comparison operator must be one of: ``<``, ``>``, ``<=``, + ``>=``, ``!=``, ``=``, or ``:``. Colon ``:`` is the contains operator. + Filter rules are not case sensitive. + + The following fields in the ``Backup`` are eligible for filtering: + + - ``name`` + - ``database`` + - ``state`` + - ``create_time`` (and values are of the format YYYY-MM-DDTHH:MM:SSZ) + - ``expire_time`` (and values are of the format YYYY-MM-DDTHH:MM:SSZ) + - ``size_bytes`` + + You can combine multiple expressions by enclosing each expression in + parentheses. By default, expressions are combined with AND logic, but + you can specify AND, OR, and NOT logic explicitly. + + Here are a few examples: + + - ``name:Howl`` - The backup's name contains the string "howl". + - ``database:prod`` - The database's name contains the string "prod". + - ``state:CREATING`` - The backup is pending creation. + - ``state:READY`` - The backup is fully created and ready for use. + - ``(name:howl) AND (create_time < \"2018-03-28T14:50:00Z\")`` - The + backup name contains the string "howl" and ``create_time`` of the + backup is before 2018-03-28T14:50:00Z. + - ``expire_time < \"2018-03-28T14:50:00Z\"`` - The backup + ``expire_time`` is before 2018-03-28T14:50:00Z. + - ``size_bytes > 10000000000`` - The backup's size is greater than 10GB + page_size (int): The maximum number of resources contained in the + underlying API response. If page streaming is performed per- + resource, this parameter does not affect the return value. If page + streaming is performed per-page, this determines the maximum number + of resources in a page. + retry (Optional[google.api_core.retry.Retry]): A retry object used + to retry requests. If ``None`` is specified, requests will + be retried using a default configuration. + timeout (Optional[float]): The amount of time, in seconds, to wait + for the request to complete. Note that if ``retry`` is + specified, the timeout applies to each individual attempt. + metadata (Optional[Sequence[Tuple[str, str]]]): Additional metadata + that is provided to the method. + + Returns: + A :class:`~google.api_core.page_iterator.PageIterator` instance. + An iterable of :class:`~google.cloud.spanner_admin_database_v1.types.Backup` instances. + You can also iterate over the pages of the response + using its `pages` property. + + Raises: + google.api_core.exceptions.GoogleAPICallError: If the request + failed for any reason. + google.api_core.exceptions.RetryError: If the request failed due + to a retryable error and retry attempts failed. + ValueError: If the parameters are invalid. + """ + # Wrap the transport method to add retry and timeout logic. + if "list_backups" not in self._inner_api_calls: + self._inner_api_calls[ + "list_backups" + ] = google.api_core.gapic_v1.method.wrap_method( + self.transport.list_backups, + default_retry=self._method_configs["ListBackups"].retry, + default_timeout=self._method_configs["ListBackups"].timeout, + client_info=self._client_info, + ) + + request = backup_pb2.ListBackupsRequest( + parent=parent, filter=filter_, page_size=page_size + ) + if metadata is None: + metadata = [] + metadata = list(metadata) + try: + routing_header = [("parent", parent)] + except AttributeError: + pass + else: + routing_metadata = google.api_core.gapic_v1.routing_header.to_grpc_metadata( + routing_header + ) + metadata.append(routing_metadata) + + iterator = google.api_core.page_iterator.GRPCIterator( + client=None, + method=functools.partial( + self._inner_api_calls["list_backups"], + retry=retry, + timeout=timeout, + metadata=metadata, + ), + request=request, + items_field="backups", + request_token_field="page_token", + response_token_field="next_page_token", + ) + return iterator + + def restore_database( + self, + parent, + database_id, + backup=None, + retry=google.api_core.gapic_v1.method.DEFAULT, + timeout=google.api_core.gapic_v1.method.DEFAULT, + metadata=None, + ): + """ + Create a new database by restoring from a completed backup. The new + database must be in the same project and in an instance with the same + instance configuration as the instance containing the backup. The + returned database ``long-running operation`` has a name of the format + ``projects//instances//databases//operations/``, + and can be used to track the progress of the operation, and to cancel + it. The ``metadata`` field type is ``RestoreDatabaseMetadata``. The + ``response`` type is ``Database``, if successful. Cancelling the + returned operation will stop the restore and delete the database. There + can be only one database being restored into an instance at a time. Once + the restore operation completes, a new restore operation can be + initiated, without waiting for the optimize operation associated with + the first restore to complete. + + Example: + >>> from google.cloud import spanner_admin_database_v1 + >>> + >>> client = spanner_admin_database_v1.DatabaseAdminClient() + >>> + >>> parent = client.instance_path('[PROJECT]', '[INSTANCE]') + >>> + >>> # TODO: Initialize `database_id`: + >>> database_id = '' + >>> + >>> response = client.restore_database(parent, database_id) + >>> + >>> def callback(operation_future): + ... # Handle result. + ... result = operation_future.result() + >>> + >>> response.add_done_callback(callback) + >>> + >>> # Handle metadata. + >>> metadata = response.metadata() + + Args: + parent (str): Required. The name of the instance in which to create the restored + database. This instance must be in the same project and have the same + instance configuration as the instance containing the source backup. + Values are of the form ``projects//instances/``. + database_id (str): Required. The id of the database to create and restore to. This database + must not already exist. The ``database_id`` appended to ``parent`` forms + the full database name of the form + ``projects//instances//databases/``. + backup (str): Name of the backup from which to restore. Values are of the form + ``projects//instances//backups/``. + retry (Optional[google.api_core.retry.Retry]): A retry object used + to retry requests. If ``None`` is specified, requests will + be retried using a default configuration. + timeout (Optional[float]): The amount of time, in seconds, to wait + for the request to complete. Note that if ``retry`` is + specified, the timeout applies to each individual attempt. + metadata (Optional[Sequence[Tuple[str, str]]]): Additional metadata + that is provided to the method. + + Returns: + A :class:`~google.cloud.spanner_admin_database_v1.types._OperationFuture` instance. + + Raises: + google.api_core.exceptions.GoogleAPICallError: If the request + failed for any reason. + google.api_core.exceptions.RetryError: If the request failed due + to a retryable error and retry attempts failed. + ValueError: If the parameters are invalid. + """ + # Wrap the transport method to add retry and timeout logic. + if "restore_database" not in self._inner_api_calls: + self._inner_api_calls[ + "restore_database" + ] = google.api_core.gapic_v1.method.wrap_method( + self.transport.restore_database, + default_retry=self._method_configs["RestoreDatabase"].retry, + default_timeout=self._method_configs["RestoreDatabase"].timeout, + client_info=self._client_info, + ) + + # Sanity check: We have some fields which are mutually exclusive; + # raise ValueError if more than one is sent. + google.api_core.protobuf_helpers.check_oneof(backup=backup) + + request = spanner_database_admin_pb2.RestoreDatabaseRequest( + parent=parent, database_id=database_id, backup=backup + ) + if metadata is None: + metadata = [] + metadata = list(metadata) + try: + routing_header = [("parent", parent)] + except AttributeError: + pass + else: + routing_metadata = google.api_core.gapic_v1.routing_header.to_grpc_metadata( + routing_header + ) + metadata.append(routing_metadata) + + operation = self._inner_api_calls["restore_database"]( + request, retry=retry, timeout=timeout, metadata=metadata + ) + return google.api_core.operation.from_gapic( + operation, + self.transport._operations_client, + spanner_database_admin_pb2.Database, + metadata_type=spanner_database_admin_pb2.RestoreDatabaseMetadata, + ) + + def list_database_operations( + self, + parent, + filter_=None, + page_size=None, + retry=google.api_core.gapic_v1.method.DEFAULT, + timeout=google.api_core.gapic_v1.method.DEFAULT, + metadata=None, + ): + """ + Lists database ``longrunning-operations``. A database operation has a + name of the form + ``projects//instances//databases//operations/``. + The long-running operation ``metadata`` field type ``metadata.type_url`` + describes the type of the metadata. Operations returned include those + that have completed/failed/canceled within the last 7 days, and pending + operations. + + Example: + >>> from google.cloud import spanner_admin_database_v1 + >>> + >>> client = spanner_admin_database_v1.DatabaseAdminClient() + >>> + >>> parent = client.instance_path('[PROJECT]', '[INSTANCE]') + >>> + >>> # Iterate over all results + >>> for element in client.list_database_operations(parent): + ... # process element + ... pass + >>> + >>> + >>> # Alternatively: + >>> + >>> # Iterate over results one page at a time + >>> for page in client.list_database_operations(parent).pages: + ... for element in page: + ... # process element + ... pass + + Args: + parent (str): Required. The instance of the database operations. Values are of the + form ``projects//instances/``. + filter_ (str): An expression that filters the list of returned operations. + + A filter expression consists of a field name, a comparison operator, and + a value for filtering. The value must be a string, a number, or a + boolean. The comparison operator must be one of: ``<``, ``>``, ``<=``, + ``>=``, ``!=``, ``=``, or ``:``. Colon ``:`` is the contains operator. + Filter rules are not case sensitive. + + The following fields in the ``Operation`` are eligible for filtering: + + - ``name`` - The name of the long-running operation + - ``done`` - False if the operation is in progress, else true. + - ``metadata.@type`` - the type of metadata. For example, the type + string for ``RestoreDatabaseMetadata`` is + ``type.googleapis.com/google.spanner.admin.database.v1.RestoreDatabaseMetadata``. + - ``metadata.`` - any field in metadata.value. + - ``error`` - Error associated with the long-running operation. + - ``response.@type`` - the type of response. + - ``response.`` - any field in response.value. + + You can combine multiple expressions by enclosing each expression in + parentheses. By default, expressions are combined with AND logic. + However, you can specify AND, OR, and NOT logic explicitly. + + Here are a few examples: + + - ``done:true`` - The operation is complete. + - ``(metadata.@type=type.googleapis.com/google.spanner.admin.database.v1.RestoreDatabaseMetadata) AND`` + ``(metadata.source_type:BACKUP) AND`` + ``(metadata.backup_info.backup:backup_howl) AND`` + ``(metadata.name:restored_howl) AND`` + ``(metadata.progress.start_time < \"2018-03-28T14:50:00Z\") AND`` + ``(error:*)`` - Return operations where: + + - The operation's metadata type is ``RestoreDatabaseMetadata``. + - The database is restored from a backup. + - The backup name contains "backup\_howl". + - The restored database's name contains "restored\_howl". + - The operation started before 2018-03-28T14:50:00Z. + - The operation resulted in an error. + page_size (int): The maximum number of resources contained in the + underlying API response. If page streaming is performed per- + resource, this parameter does not affect the return value. If page + streaming is performed per-page, this determines the maximum number + of resources in a page. + retry (Optional[google.api_core.retry.Retry]): A retry object used + to retry requests. If ``None`` is specified, requests will + be retried using a default configuration. + timeout (Optional[float]): The amount of time, in seconds, to wait + for the request to complete. Note that if ``retry`` is + specified, the timeout applies to each individual attempt. + metadata (Optional[Sequence[Tuple[str, str]]]): Additional metadata + that is provided to the method. + + Returns: + A :class:`~google.api_core.page_iterator.PageIterator` instance. + An iterable of :class:`~google.cloud.spanner_admin_database_v1.types.Operation` instances. + You can also iterate over the pages of the response + using its `pages` property. + + Raises: + google.api_core.exceptions.GoogleAPICallError: If the request + failed for any reason. + google.api_core.exceptions.RetryError: If the request failed due + to a retryable error and retry attempts failed. + ValueError: If the parameters are invalid. + """ + # Wrap the transport method to add retry and timeout logic. + if "list_database_operations" not in self._inner_api_calls: + self._inner_api_calls[ + "list_database_operations" + ] = google.api_core.gapic_v1.method.wrap_method( + self.transport.list_database_operations, + default_retry=self._method_configs["ListDatabaseOperations"].retry, + default_timeout=self._method_configs["ListDatabaseOperations"].timeout, + client_info=self._client_info, + ) + + request = spanner_database_admin_pb2.ListDatabaseOperationsRequest( + parent=parent, filter=filter_, page_size=page_size + ) + if metadata is None: + metadata = [] + metadata = list(metadata) + try: + routing_header = [("parent", parent)] + except AttributeError: + pass + else: + routing_metadata = google.api_core.gapic_v1.routing_header.to_grpc_metadata( + routing_header + ) + metadata.append(routing_metadata) + + iterator = google.api_core.page_iterator.GRPCIterator( + client=None, + method=functools.partial( + self._inner_api_calls["list_database_operations"], + retry=retry, + timeout=timeout, + metadata=metadata, + ), + request=request, + items_field="operations", + request_token_field="page_token", + response_token_field="next_page_token", + ) + return iterator + + def list_backup_operations( + self, + parent, + filter_=None, + page_size=None, + retry=google.api_core.gapic_v1.method.DEFAULT, + timeout=google.api_core.gapic_v1.method.DEFAULT, + metadata=None, + ): + """ + Lists the backup ``long-running operations`` in the given instance. A + backup operation has a name of the form + ``projects//instances//backups//operations/``. + The long-running operation ``metadata`` field type ``metadata.type_url`` + describes the type of the metadata. Operations returned include those + that have completed/failed/canceled within the last 7 days, and pending + operations. Operations returned are ordered by + ``operation.metadata.value.progress.start_time`` in descending order + starting from the most recently started operation. + + Example: + >>> from google.cloud import spanner_admin_database_v1 + >>> + >>> client = spanner_admin_database_v1.DatabaseAdminClient() + >>> + >>> parent = client.instance_path('[PROJECT]', '[INSTANCE]') + >>> + >>> # Iterate over all results + >>> for element in client.list_backup_operations(parent): + ... # process element + ... pass + >>> + >>> + >>> # Alternatively: + >>> + >>> # Iterate over results one page at a time + >>> for page in client.list_backup_operations(parent).pages: + ... for element in page: + ... # process element + ... pass + + Args: + parent (str): Required. The instance of the backup operations. Values are of the form + ``projects//instances/``. + filter_ (str): An expression that filters the list of returned backup operations. + + A filter expression consists of a field name, a comparison operator, and + a value for filtering. The value must be a string, a number, or a + boolean. The comparison operator must be one of: ``<``, ``>``, ``<=``, + ``>=``, ``!=``, ``=``, or ``:``. Colon ``:`` is the contains operator. + Filter rules are not case sensitive. + + The following fields in the ``operation`` are eligible for filtering: + + - ``name`` - The name of the long-running operation + - ``done`` - False if the operation is in progress, else true. + - ``metadata.@type`` - the type of metadata. For example, the type + string for ``CreateBackupMetadata`` is + ``type.googleapis.com/google.spanner.admin.database.v1.CreateBackupMetadata``. + - ``metadata.`` - any field in metadata.value. + - ``error`` - Error associated with the long-running operation. + - ``response.@type`` - the type of response. + - ``response.`` - any field in response.value. + + You can combine multiple expressions by enclosing each expression in + parentheses. By default, expressions are combined with AND logic, but + you can specify AND, OR, and NOT logic explicitly. + + Here are a few examples: + + - ``done:true`` - The operation is complete. + - ``metadata.database:prod`` - The database the backup was taken from + has a name containing the string "prod". + - ``(metadata.@type=type.googleapis.com/google.spanner.admin.database.v1.CreateBackupMetadata) AND`` + ``(metadata.name:howl) AND`` + ``(metadata.progress.start_time < \"2018-03-28T14:50:00Z\") AND`` + ``(error:*)`` - Returns operations where: + + - The operation's metadata type is ``CreateBackupMetadata``. + - The backup name contains the string "howl". + - The operation started before 2018-03-28T14:50:00Z. + - The operation resulted in an error. + page_size (int): The maximum number of resources contained in the + underlying API response. If page streaming is performed per- + resource, this parameter does not affect the return value. If page + streaming is performed per-page, this determines the maximum number + of resources in a page. + retry (Optional[google.api_core.retry.Retry]): A retry object used + to retry requests. If ``None`` is specified, requests will + be retried using a default configuration. + timeout (Optional[float]): The amount of time, in seconds, to wait + for the request to complete. Note that if ``retry`` is + specified, the timeout applies to each individual attempt. + metadata (Optional[Sequence[Tuple[str, str]]]): Additional metadata + that is provided to the method. + + Returns: + A :class:`~google.api_core.page_iterator.PageIterator` instance. + An iterable of :class:`~google.cloud.spanner_admin_database_v1.types.Operation` instances. + You can also iterate over the pages of the response + using its `pages` property. + + Raises: + google.api_core.exceptions.GoogleAPICallError: If the request + failed for any reason. + google.api_core.exceptions.RetryError: If the request failed due + to a retryable error and retry attempts failed. + ValueError: If the parameters are invalid. + """ + # Wrap the transport method to add retry and timeout logic. + if "list_backup_operations" not in self._inner_api_calls: + self._inner_api_calls[ + "list_backup_operations" + ] = google.api_core.gapic_v1.method.wrap_method( + self.transport.list_backup_operations, + default_retry=self._method_configs["ListBackupOperations"].retry, + default_timeout=self._method_configs["ListBackupOperations"].timeout, + client_info=self._client_info, + ) + + request = backup_pb2.ListBackupOperationsRequest( + parent=parent, filter=filter_, page_size=page_size + ) + if metadata is None: + metadata = [] + metadata = list(metadata) + try: + routing_header = [("parent", parent)] + except AttributeError: + pass + else: + routing_metadata = google.api_core.gapic_v1.routing_header.to_grpc_metadata( + routing_header + ) + metadata.append(routing_metadata) + + iterator = google.api_core.page_iterator.GRPCIterator( + client=None, + method=functools.partial( + self._inner_api_calls["list_backup_operations"], + retry=retry, + timeout=timeout, + metadata=metadata, + ), + request=request, + items_field="operations", + request_token_field="page_token", + response_token_field="next_page_token", + ) + return iterator + def list_databases( self, parent, diff --git a/google/cloud/spanner_admin_database_v1/gapic/database_admin_client_config.py b/google/cloud/spanner_admin_database_v1/gapic/database_admin_client_config.py index 90c9f796e2..d6f830eeee 100644 --- a/google/cloud/spanner_admin_database_v1/gapic/database_admin_client_config.py +++ b/google/cloud/spanner_admin_database_v1/gapic/database_admin_client_config.py @@ -57,6 +57,46 @@ "retry_codes_name": "non_idempotent", "retry_params_name": "default", }, + "CreateBackup": { + "timeout_millis": 30000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default", + }, + "GetBackup": { + "timeout_millis": 30000, + "retry_codes_name": "idempotent", + "retry_params_name": "default", + }, + "UpdateBackup": { + "timeout_millis": 30000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default", + }, + "DeleteBackup": { + "timeout_millis": 30000, + "retry_codes_name": "idempotent", + "retry_params_name": "default", + }, + "ListBackups": { + "timeout_millis": 30000, + "retry_codes_name": "idempotent", + "retry_params_name": "default", + }, + "RestoreDatabase": { + "timeout_millis": 30000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default", + }, + "ListDatabaseOperations": { + "timeout_millis": 30000, + "retry_codes_name": "idempotent", + "retry_params_name": "default", + }, + "ListBackupOperations": { + "timeout_millis": 30000, + "retry_codes_name": "idempotent", + "retry_params_name": "default", + }, "ListDatabases": { "timeout_millis": 60000, "retry_codes_name": "idempotent", diff --git a/google/cloud/spanner_admin_database_v1/gapic/enums.py b/google/cloud/spanner_admin_database_v1/gapic/enums.py index aa1a519027..d972ddfc57 100644 --- a/google/cloud/spanner_admin_database_v1/gapic/enums.py +++ b/google/cloud/spanner_admin_database_v1/gapic/enums.py @@ -19,6 +19,36 @@ import enum +class RestoreSourceType(enum.IntEnum): + """ + Indicates the type of the restore source. + + Attributes: + TYPE_UNSPECIFIED (int): No restore associated. + BACKUP (int): A backup was used as the source of the restore. + """ + + TYPE_UNSPECIFIED = 0 + BACKUP = 1 + + +class Backup(object): + class State(enum.IntEnum): + """ + Indicates the current state of the backup. + + Attributes: + STATE_UNSPECIFIED (int): Not specified. + CREATING (int): The pending backup is still being created. Operations on the backup may + fail with ``FAILED_PRECONDITION`` in this state. + READY (int): The backup is complete and ready for use. + """ + + STATE_UNSPECIFIED = 0 + CREATING = 1 + READY = 2 + + class Database(object): class State(enum.IntEnum): """ @@ -29,8 +59,16 @@ class State(enum.IntEnum): CREATING (int): The database is still being created. Operations on the database may fail with ``FAILED_PRECONDITION`` in this state. READY (int): The database is fully created and ready for use. + READY_OPTIMIZING (int): The database is fully created and ready for use, but is still being + optimized for performance and cannot handle full load. + + In this state, the database still references the backup it was restore + from, preventing the backup from being deleted. When optimizations are + complete, the full performance of the database will be restored, and the + database will transition to ``READY`` state. """ STATE_UNSPECIFIED = 0 CREATING = 1 READY = 2 + READY_OPTIMIZING = 3 diff --git a/google/cloud/spanner_admin_database_v1/gapic/transports/database_admin_grpc_transport.py b/google/cloud/spanner_admin_database_v1/gapic/transports/database_admin_grpc_transport.py index cd56873704..2fb41caab2 100644 --- a/google/cloud/spanner_admin_database_v1/gapic/transports/database_admin_grpc_transport.py +++ b/google/cloud/spanner_admin_database_v1/gapic/transports/database_admin_grpc_transport.py @@ -173,7 +173,8 @@ def update_database_ddl(self): def drop_database(self): """Return the gRPC stub for :meth:`DatabaseAdminClient.drop_database`. - Drops (aka deletes) a Cloud Spanner database. + Drops (aka deletes) a Cloud Spanner database. Completed backups for the + database will be retained according to their ``expire_time``. Returns: Callable: A callable which accepts the appropriate @@ -201,11 +202,12 @@ def get_database_ddl(self): def set_iam_policy(self): """Return the gRPC stub for :meth:`DatabaseAdminClient.set_iam_policy`. - Sets the access control policy on a database resource. Replaces any - existing policy. + Sets the access control policy on a database or backup resource. + Replaces any existing policy. Authorization requires ``spanner.databases.setIamPolicy`` permission on - ``resource``. + ``resource``. For backups, authorization requires + ``spanner.backups.setIamPolicy`` permission on ``resource``. Returns: Callable: A callable which accepts the appropriate @@ -218,11 +220,13 @@ def set_iam_policy(self): def get_iam_policy(self): """Return the gRPC stub for :meth:`DatabaseAdminClient.get_iam_policy`. - Gets the access control policy for a database resource. Returns an empty - policy if a database exists but does not have a policy set. + Gets the access control policy for a database or backup resource. + Returns an empty policy if a database or backup exists but does not have + a policy set. Authorization requires ``spanner.databases.getIamPolicy`` permission on - ``resource``. + ``resource``. For backups, authorization requires + ``spanner.backups.getIamPolicy`` permission on ``resource``. Returns: Callable: A callable which accepts the appropriate @@ -235,13 +239,15 @@ def get_iam_policy(self): def test_iam_permissions(self): """Return the gRPC stub for :meth:`DatabaseAdminClient.test_iam_permissions`. - Returns permissions that the caller has on the specified database - resource. + Returns permissions that the caller has on the specified database or + backup resource. Attempting this RPC on a non-existent Cloud Spanner database will result in a NOT\_FOUND error if the user has ``spanner.databases.list`` permission on the containing Cloud Spanner instance. Otherwise returns - an empty set of permissions. + an empty set of permissions. Calling this method on a backup that does + not exist will result in a NOT\_FOUND error if the user has + ``spanner.backups.list`` permission on the containing instance. Returns: Callable: A callable which accepts the appropriate @@ -250,6 +256,146 @@ def test_iam_permissions(self): """ return self._stubs["database_admin_stub"].TestIamPermissions + @property + def create_backup(self): + """Return the gRPC stub for :meth:`DatabaseAdminClient.create_backup`. + + Starts creating a new Cloud Spanner Backup. The returned backup + ``long-running operation`` will have a name of the format + ``projects//instances//backups//operations/`` + and can be used to track creation of the backup. The ``metadata`` field + type is ``CreateBackupMetadata``. The ``response`` field type is + ``Backup``, if successful. Cancelling the returned operation will stop + the creation and delete the backup. There can be only one pending backup + creation per database. Backup creation of different databases can run + concurrently. + + Returns: + Callable: A callable which accepts the appropriate + deserialized request object and returns a + deserialized response object. + """ + return self._stubs["database_admin_stub"].CreateBackup + + @property + def get_backup(self): + """Return the gRPC stub for :meth:`DatabaseAdminClient.get_backup`. + + Gets metadata on a pending or completed ``Backup``. + + Returns: + Callable: A callable which accepts the appropriate + deserialized request object and returns a + deserialized response object. + """ + return self._stubs["database_admin_stub"].GetBackup + + @property + def update_backup(self): + """Return the gRPC stub for :meth:`DatabaseAdminClient.update_backup`. + + Updates a pending or completed ``Backup``. + + Returns: + Callable: A callable which accepts the appropriate + deserialized request object and returns a + deserialized response object. + """ + return self._stubs["database_admin_stub"].UpdateBackup + + @property + def delete_backup(self): + """Return the gRPC stub for :meth:`DatabaseAdminClient.delete_backup`. + + Deletes a pending or completed ``Backup``. + + Returns: + Callable: A callable which accepts the appropriate + deserialized request object and returns a + deserialized response object. + """ + return self._stubs["database_admin_stub"].DeleteBackup + + @property + def list_backups(self): + """Return the gRPC stub for :meth:`DatabaseAdminClient.list_backups`. + + Lists completed and pending backups. Backups returned are ordered by + ``create_time`` in descending order, starting from the most recent + ``create_time``. + + Returns: + Callable: A callable which accepts the appropriate + deserialized request object and returns a + deserialized response object. + """ + return self._stubs["database_admin_stub"].ListBackups + + @property + def restore_database(self): + """Return the gRPC stub for :meth:`DatabaseAdminClient.restore_database`. + + Create a new database by restoring from a completed backup. The new + database must be in the same project and in an instance with the same + instance configuration as the instance containing the backup. The + returned database ``long-running operation`` has a name of the format + ``projects//instances//databases//operations/``, + and can be used to track the progress of the operation, and to cancel + it. The ``metadata`` field type is ``RestoreDatabaseMetadata``. The + ``response`` type is ``Database``, if successful. Cancelling the + returned operation will stop the restore and delete the database. There + can be only one database being restored into an instance at a time. Once + the restore operation completes, a new restore operation can be + initiated, without waiting for the optimize operation associated with + the first restore to complete. + + Returns: + Callable: A callable which accepts the appropriate + deserialized request object and returns a + deserialized response object. + """ + return self._stubs["database_admin_stub"].RestoreDatabase + + @property + def list_database_operations(self): + """Return the gRPC stub for :meth:`DatabaseAdminClient.list_database_operations`. + + Lists database ``longrunning-operations``. A database operation has a + name of the form + ``projects//instances//databases//operations/``. + The long-running operation ``metadata`` field type ``metadata.type_url`` + describes the type of the metadata. Operations returned include those + that have completed/failed/canceled within the last 7 days, and pending + operations. + + Returns: + Callable: A callable which accepts the appropriate + deserialized request object and returns a + deserialized response object. + """ + return self._stubs["database_admin_stub"].ListDatabaseOperations + + @property + def list_backup_operations(self): + """Return the gRPC stub for :meth:`DatabaseAdminClient.list_backup_operations`. + + Lists the backup ``long-running operations`` in the given instance. A + backup operation has a name of the form + ``projects//instances//backups//operations/``. + The long-running operation ``metadata`` field type ``metadata.type_url`` + describes the type of the metadata. Operations returned include those + that have completed/failed/canceled within the last 7 days, and pending + operations. Operations returned are ordered by + ``operation.metadata.value.progress.start_time`` in descending order + starting from the most recently started operation. + + Returns: + Callable: A callable which accepts the appropriate + deserialized request object and returns a + deserialized response object. + """ + return self._stubs["database_admin_stub"].ListBackupOperations + @property def list_databases(self): """Return the gRPC stub for :meth:`DatabaseAdminClient.list_databases`. diff --git a/google/cloud/spanner_admin_database_v1/proto/backup.proto b/google/cloud/spanner_admin_database_v1/proto/backup.proto new file mode 100644 index 0000000000..d9b6fd74cd --- /dev/null +++ b/google/cloud/spanner_admin_database_v1/proto/backup.proto @@ -0,0 +1,363 @@ +// Copyright 2020 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.spanner.admin.database.v1; + +import "google/api/field_behavior.proto"; +import "google/api/resource.proto"; +import "google/longrunning/operations.proto"; +import "google/protobuf/field_mask.proto"; +import "google/protobuf/timestamp.proto"; +import "google/spanner/admin/database/v1/common.proto"; +import "google/api/annotations.proto"; + +option csharp_namespace = "Google.Cloud.Spanner.Admin.Database.V1"; +option go_package = "google.golang.org/genproto/googleapis/spanner/admin/database/v1;database"; +option java_multiple_files = true; +option java_outer_classname = "BackupProto"; +option java_package = "com.google.spanner.admin.database.v1"; +option php_namespace = "Google\\Cloud\\Spanner\\Admin\\Database\\V1"; + +// A backup of a Cloud Spanner database. +message Backup { + option (google.api.resource) = { + type: "spanner.googleapis.com/Backup" + pattern: "projects/{project}/instances/{instance}/backups/{backup}" + }; + + // Indicates the current state of the backup. + enum State { + // Not specified. + STATE_UNSPECIFIED = 0; + + // The pending backup is still being created. Operations on the + // backup may fail with `FAILED_PRECONDITION` in this state. + CREATING = 1; + + // The backup is complete and ready for use. + READY = 2; + } + + // Required for the [CreateBackup][google.spanner.admin.database.v1.DatabaseAdmin.CreateBackup] operation. + // Name of the database from which this backup was + // created. This needs to be in the same instance as the backup. + // Values are of the form + // `projects//instances//databases/`. + string database = 2; + + // Required for the [CreateBackup][google.spanner.admin.database.v1.DatabaseAdmin.CreateBackup] + // operation. The expiration time of the backup, with microseconds + // granularity that must be at least 6 hours and at most 366 days + // from the time the CreateBackup request is processed. Once the `expire_time` + // has passed, the backup is eligible to be automatically deleted by Cloud + // Spanner to free the resources used by the backup. + google.protobuf.Timestamp expire_time = 3; + + // Output only for the [CreateBackup][google.spanner.admin.database.v1.DatabaseAdmin.CreateBackup] operation. + // Required for the [UpdateBackup][google.spanner.admin.database.v1.DatabaseAdmin.UpdateBackup] operation. + // + // A globally unique identifier for the backup which cannot be + // changed. Values are of the form + // `projects//instances//backups/[a-z][a-z0-9_\-]*[a-z0-9]` + // The final segment of the name must be between 2 and 60 characters + // in length. + // + // The backup is stored in the location(s) specified in the instance + // configuration of the instance containing the backup, identified + // by the prefix of the backup name of the form + // `projects//instances/`. + string name = 1; + + // Output only. The backup will contain an externally consistent + // copy of the database at the timestamp specified by + // `create_time`. `create_time` is approximately the time the + // [CreateBackup][google.spanner.admin.database.v1.DatabaseAdmin.CreateBackup] request is received. + google.protobuf.Timestamp create_time = 4 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. Size of the backup in bytes. + int64 size_bytes = 5 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. The current state of the backup. + State state = 6 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. The names of the restored databases that reference the backup. + // The database names are of + // the form `projects//instances//databases/`. + // Referencing databases may exist in different instances. The existence of + // any referencing database prevents the backup from being deleted. When a + // restored database from the backup enters the `READY` state, the reference + // to the backup is removed. + repeated string referencing_databases = 7 [(google.api.field_behavior) = OUTPUT_ONLY]; +} + +// The request for [CreateBackup][google.spanner.admin.database.v1.DatabaseAdmin.CreateBackup]. +message CreateBackupRequest { + // Required. The name of the instance in which the backup will be + // created. This must be the same instance that contains the database the + // backup will be created from. The backup will be stored in the + // location(s) specified in the instance configuration of this + // instance. Values are of the form + // `projects//instances/`. + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "spanner.googleapis.com/Instance" + } + ]; + + // Required. The id of the backup to be created. The `backup_id` appended to + // `parent` forms the full backup name of the form + // `projects//instances//backups/`. + string backup_id = 2 [(google.api.field_behavior) = REQUIRED]; + + // Required. The backup to create. + Backup backup = 3 [(google.api.field_behavior) = REQUIRED]; +} + +// Metadata type for the operation returned by +// [CreateBackup][google.spanner.admin.database.v1.DatabaseAdmin.CreateBackup]. +message CreateBackupMetadata { + // The name of the backup being created. + string name = 1; + + // The name of the database the backup is created from. + string database = 2; + + // The progress of the + // [CreateBackup][google.spanner.admin.database.v1.DatabaseAdmin.CreateBackup] operation. + OperationProgress progress = 3; + + // The time at which cancellation of this operation was received. + // [Operations.CancelOperation][google.longrunning.Operations.CancelOperation] + // starts asynchronous cancellation on a long-running operation. The server + // makes a best effort to cancel the operation, but success is not guaranteed. + // Clients can use + // [Operations.GetOperation][google.longrunning.Operations.GetOperation] or + // other methods to check whether the cancellation succeeded or whether the + // operation completed despite cancellation. On successful cancellation, + // the operation is not deleted; instead, it becomes an operation with + // an [Operation.error][] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1, + // corresponding to `Code.CANCELLED`. + google.protobuf.Timestamp cancel_time = 4; +} + +// The request for [UpdateBackup][google.spanner.admin.database.v1.DatabaseAdmin.UpdateBackup]. +message UpdateBackupRequest { + // Required. The backup to update. `backup.name`, and the fields to be updated + // as specified by `update_mask` are required. Other fields are ignored. + // Update is only supported for the following fields: + // * `backup.expire_time`. + Backup backup = 1 [(google.api.field_behavior) = REQUIRED]; + + // Required. A mask specifying which fields (e.g. `expire_time`) in the + // Backup resource should be updated. This mask is relative to the Backup + // resource, not to the request message. The field mask must always be + // specified; this prevents any future fields from being erased accidentally + // by clients that do not know about them. + google.protobuf.FieldMask update_mask = 2 [(google.api.field_behavior) = REQUIRED]; +} + +// The request for [GetBackup][google.spanner.admin.database.v1.DatabaseAdmin.GetBackup]. +message GetBackupRequest { + // Required. Name of the backup. + // Values are of the form + // `projects//instances//backups/`. + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "spanner.googleapis.com/Backup" + } + ]; +} + +// The request for [DeleteBackup][google.spanner.admin.database.v1.DatabaseAdmin.DeleteBackup]. +message DeleteBackupRequest { + // Required. Name of the backup to delete. + // Values are of the form + // `projects//instances//backups/`. + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "spanner.googleapis.com/Backup" + } + ]; +} + +// The request for [ListBackups][google.spanner.admin.database.v1.DatabaseAdmin.ListBackups]. +message ListBackupsRequest { + // Required. The instance to list backups from. Values are of the + // form `projects//instances/`. + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "spanner.googleapis.com/Instance" + } + ]; + + // An expression that filters the list of returned backups. + // + // A filter expression consists of a field name, a comparison operator, and a + // value for filtering. + // The value must be a string, a number, or a boolean. The comparison operator + // must be one of: `<`, `>`, `<=`, `>=`, `!=`, `=`, or `:`. + // Colon `:` is the contains operator. Filter rules are not case sensitive. + // + // The following fields in the [Backup][google.spanner.admin.database.v1.Backup] are eligible for filtering: + // + // * `name` + // * `database` + // * `state` + // * `create_time` (and values are of the format YYYY-MM-DDTHH:MM:SSZ) + // * `expire_time` (and values are of the format YYYY-MM-DDTHH:MM:SSZ) + // * `size_bytes` + // + // You can combine multiple expressions by enclosing each expression in + // parentheses. By default, expressions are combined with AND logic, but + // you can specify AND, OR, and NOT logic explicitly. + // + // Here are a few examples: + // + // * `name:Howl` - The backup's name contains the string "howl". + // * `database:prod` + // - The database's name contains the string "prod". + // * `state:CREATING` - The backup is pending creation. + // * `state:READY` - The backup is fully created and ready for use. + // * `(name:howl) AND (create_time < \"2018-03-28T14:50:00Z\")` + // - The backup name contains the string "howl" and `create_time` + // of the backup is before 2018-03-28T14:50:00Z. + // * `expire_time < \"2018-03-28T14:50:00Z\"` + // - The backup `expire_time` is before 2018-03-28T14:50:00Z. + // * `size_bytes > 10000000000` - The backup's size is greater than 10GB + string filter = 2; + + // Number of backups to be returned in the response. If 0 or + // less, defaults to the server's maximum allowed page size. + int32 page_size = 3; + + // If non-empty, `page_token` should contain a + // [next_page_token][google.spanner.admin.database.v1.ListBackupsResponse.next_page_token] from a + // previous [ListBackupsResponse][google.spanner.admin.database.v1.ListBackupsResponse] to the same `parent` and with the same + // `filter`. + string page_token = 4; +} + +// The response for [ListBackups][google.spanner.admin.database.v1.DatabaseAdmin.ListBackups]. +message ListBackupsResponse { + // The list of matching backups. Backups returned are ordered by `create_time` + // in descending order, starting from the most recent `create_time`. + repeated Backup backups = 1; + + // `next_page_token` can be sent in a subsequent + // [ListBackups][google.spanner.admin.database.v1.DatabaseAdmin.ListBackups] call to fetch more + // of the matching backups. + string next_page_token = 2; +} + +// The request for +// [ListBackupOperations][google.spanner.admin.database.v1.DatabaseAdmin.ListBackupOperations]. +message ListBackupOperationsRequest { + // Required. The instance of the backup operations. Values are of + // the form `projects//instances/`. + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "spanner.googleapis.com/Instance" + } + ]; + + // An expression that filters the list of returned backup operations. + // + // A filter expression consists of a field name, a + // comparison operator, and a value for filtering. + // The value must be a string, a number, or a boolean. The comparison operator + // must be one of: `<`, `>`, `<=`, `>=`, `!=`, `=`, or `:`. + // Colon `:` is the contains operator. Filter rules are not case sensitive. + // + // The following fields in the [operation][google.longrunning.Operation] + // are eligible for filtering: + // + // * `name` - The name of the long-running operation + // * `done` - False if the operation is in progress, else true. + // * `metadata.@type` - the type of metadata. For example, the type string + // for [CreateBackupMetadata][google.spanner.admin.database.v1.CreateBackupMetadata] is + // `type.googleapis.com/google.spanner.admin.database.v1.CreateBackupMetadata`. + // * `metadata.` - any field in metadata.value. + // * `error` - Error associated with the long-running operation. + // * `response.@type` - the type of response. + // * `response.` - any field in response.value. + // + // You can combine multiple expressions by enclosing each expression in + // parentheses. By default, expressions are combined with AND logic, but + // you can specify AND, OR, and NOT logic explicitly. + // + // Here are a few examples: + // + // * `done:true` - The operation is complete. + // * `metadata.database:prod` - The database the backup was taken from has + // a name containing the string "prod". + // * `(metadata.@type=type.googleapis.com/google.spanner.admin.database.v1.CreateBackupMetadata) AND`
+ // `(metadata.name:howl) AND`
+ // `(metadata.progress.start_time < \"2018-03-28T14:50:00Z\") AND`
+ // `(error:*)` - Returns operations where: + // * The operation's metadata type is [CreateBackupMetadata][google.spanner.admin.database.v1.CreateBackupMetadata]. + // * The backup name contains the string "howl". + // * The operation started before 2018-03-28T14:50:00Z. + // * The operation resulted in an error. + string filter = 2; + + // Number of operations to be returned in the response. If 0 or + // less, defaults to the server's maximum allowed page size. + int32 page_size = 3; + + // If non-empty, `page_token` should contain a + // [next_page_token][google.spanner.admin.database.v1.ListBackupOperationsResponse.next_page_token] + // from a previous [ListBackupOperationsResponse][google.spanner.admin.database.v1.ListBackupOperationsResponse] to the + // same `parent` and with the same `filter`. + string page_token = 4; +} + +// The response for +// [ListBackupOperations][google.spanner.admin.database.v1.DatabaseAdmin.ListBackupOperations]. +message ListBackupOperationsResponse { + // The list of matching backup [long-running + // operations][google.longrunning.Operation]. Each operation's name will be + // prefixed by the backup's name and the operation's + // [metadata][google.longrunning.Operation.metadata] will be of type + // [CreateBackupMetadata][google.spanner.admin.database.v1.CreateBackupMetadata]. Operations returned include those that are + // pending or have completed/failed/canceled within the last 7 days. + // Operations returned are ordered by + // `operation.metadata.value.progress.start_time` in descending order starting + // from the most recently started operation. + repeated google.longrunning.Operation operations = 1; + + // `next_page_token` can be sent in a subsequent + // [ListBackupOperations][google.spanner.admin.database.v1.DatabaseAdmin.ListBackupOperations] + // call to fetch more of the matching metadata. + string next_page_token = 2; +} + +// Information about a backup. +message BackupInfo { + // Name of the backup. + string backup = 1; + + // The backup contains an externally consistent copy of `source_database` at + // the timestamp specified by `create_time`. + google.protobuf.Timestamp create_time = 2; + + // Name of the database the backup was created from. + string source_database = 3; +} diff --git a/google/cloud/spanner_admin_database_v1/proto/backup_pb2.py b/google/cloud/spanner_admin_database_v1/proto/backup_pb2.py new file mode 100644 index 0000000000..edc596bd94 --- /dev/null +++ b/google/cloud/spanner_admin_database_v1/proto/backup_pb2.py @@ -0,0 +1,1379 @@ +# -*- coding: utf-8 -*- +# Generated by the protocol buffer compiler. DO NOT EDIT! +# source: google/cloud/spanner/admin/database_v1/proto/backup.proto + +import sys + +_b = sys.version_info[0] < 3 and (lambda x: x) or (lambda x: x.encode("latin1")) +from google.protobuf import descriptor as _descriptor +from google.protobuf import message as _message +from google.protobuf import reflection as _reflection +from google.protobuf import symbol_database as _symbol_database + +# @@protoc_insertion_point(imports) + +_sym_db = _symbol_database.Default() + + +from google.api import field_behavior_pb2 as google_dot_api_dot_field__behavior__pb2 +from google.api import resource_pb2 as google_dot_api_dot_resource__pb2 +from google.longrunning import ( + operations_pb2 as google_dot_longrunning_dot_operations__pb2, +) +from google.protobuf import field_mask_pb2 as google_dot_protobuf_dot_field__mask__pb2 +from google.protobuf import timestamp_pb2 as google_dot_protobuf_dot_timestamp__pb2 +from google.cloud.spanner_admin_database_v1.proto import ( + common_pb2 as google_dot_cloud_dot_spanner_dot_admin_dot_database__v1_dot_proto_dot_common__pb2, +) +from google.api import annotations_pb2 as google_dot_api_dot_annotations__pb2 + + +DESCRIPTOR = _descriptor.FileDescriptor( + name="google/cloud/spanner/admin/database_v1/proto/backup.proto", + package="google.spanner.admin.database.v1", + syntax="proto3", + serialized_options=_b( + "\n$com.google.spanner.admin.database.v1B\013BackupProtoP\001ZHgoogle.golang.org/genproto/googleapis/spanner/admin/database/v1;database\252\002&Google.Cloud.Spanner.Admin.Database.V1\312\002&Google\\Cloud\\Spanner\\Admin\\Database\\V1" + ), + serialized_pb=_b( + '\n9google/cloud/spanner/admin/database_v1/proto/backup.proto\x12 google.spanner.admin.database.v1\x1a\x1fgoogle/api/field_behavior.proto\x1a\x19google/api/resource.proto\x1a#google/longrunning/operations.proto\x1a google/protobuf/field_mask.proto\x1a\x1fgoogle/protobuf/timestamp.proto\x1a\x39google/cloud/spanner/admin/database_v1/proto/common.proto\x1a\x1cgoogle/api/annotations.proto"\xa7\x03\n\x06\x42\x61\x63kup\x12\x10\n\x08\x64\x61tabase\x18\x02 \x01(\t\x12/\n\x0b\x65xpire_time\x18\x03 \x01(\x0b\x32\x1a.google.protobuf.Timestamp\x12\x0c\n\x04name\x18\x01 \x01(\t\x12\x34\n\x0b\x63reate_time\x18\x04 \x01(\x0b\x32\x1a.google.protobuf.TimestampB\x03\xe0\x41\x03\x12\x17\n\nsize_bytes\x18\x05 \x01(\x03\x42\x03\xe0\x41\x03\x12\x42\n\x05state\x18\x06 \x01(\x0e\x32..google.spanner.admin.database.v1.Backup.StateB\x03\xe0\x41\x03\x12"\n\x15referencing_databases\x18\x07 \x03(\tB\x03\xe0\x41\x03"7\n\x05State\x12\x15\n\x11STATE_UNSPECIFIED\x10\x00\x12\x0c\n\x08\x43REATING\x10\x01\x12\t\n\x05READY\x10\x02:\\\xea\x41Y\n\x1dspanner.googleapis.com/Backup\x12\x38projects/{project}/instances/{instance}/backups/{backup}"\xa5\x01\n\x13\x43reateBackupRequest\x12\x37\n\x06parent\x18\x01 \x01(\tB\'\xe0\x41\x02\xfa\x41!\n\x1fspanner.googleapis.com/Instance\x12\x16\n\tbackup_id\x18\x02 \x01(\tB\x03\xe0\x41\x02\x12=\n\x06\x62\x61\x63kup\x18\x03 \x01(\x0b\x32(.google.spanner.admin.database.v1.BackupB\x03\xe0\x41\x02"\xae\x01\n\x14\x43reateBackupMetadata\x12\x0c\n\x04name\x18\x01 \x01(\t\x12\x10\n\x08\x64\x61tabase\x18\x02 \x01(\t\x12\x45\n\x08progress\x18\x03 \x01(\x0b\x32\x33.google.spanner.admin.database.v1.OperationProgress\x12/\n\x0b\x63\x61ncel_time\x18\x04 \x01(\x0b\x32\x1a.google.protobuf.Timestamp"\x8a\x01\n\x13UpdateBackupRequest\x12=\n\x06\x62\x61\x63kup\x18\x01 \x01(\x0b\x32(.google.spanner.admin.database.v1.BackupB\x03\xe0\x41\x02\x12\x34\n\x0bupdate_mask\x18\x02 \x01(\x0b\x32\x1a.google.protobuf.FieldMaskB\x03\xe0\x41\x02"G\n\x10GetBackupRequest\x12\x33\n\x04name\x18\x01 \x01(\tB%\xe0\x41\x02\xfa\x41\x1f\n\x1dspanner.googleapis.com/Backup"J\n\x13\x44\x65leteBackupRequest\x12\x33\n\x04name\x18\x01 \x01(\tB%\xe0\x41\x02\xfa\x41\x1f\n\x1dspanner.googleapis.com/Backup"\x84\x01\n\x12ListBackupsRequest\x12\x37\n\x06parent\x18\x01 \x01(\tB\'\xe0\x41\x02\xfa\x41!\n\x1fspanner.googleapis.com/Instance\x12\x0e\n\x06\x66ilter\x18\x02 \x01(\t\x12\x11\n\tpage_size\x18\x03 \x01(\x05\x12\x12\n\npage_token\x18\x04 \x01(\t"i\n\x13ListBackupsResponse\x12\x39\n\x07\x62\x61\x63kups\x18\x01 \x03(\x0b\x32(.google.spanner.admin.database.v1.Backup\x12\x17\n\x0fnext_page_token\x18\x02 \x01(\t"\x8d\x01\n\x1bListBackupOperationsRequest\x12\x37\n\x06parent\x18\x01 \x01(\tB\'\xe0\x41\x02\xfa\x41!\n\x1fspanner.googleapis.com/Instance\x12\x0e\n\x06\x66ilter\x18\x02 \x01(\t\x12\x11\n\tpage_size\x18\x03 \x01(\x05\x12\x12\n\npage_token\x18\x04 \x01(\t"j\n\x1cListBackupOperationsResponse\x12\x31\n\noperations\x18\x01 \x03(\x0b\x32\x1d.google.longrunning.Operation\x12\x17\n\x0fnext_page_token\x18\x02 \x01(\t"f\n\nBackupInfo\x12\x0e\n\x06\x62\x61\x63kup\x18\x01 \x01(\t\x12/\n\x0b\x63reate_time\x18\x02 \x01(\x0b\x32\x1a.google.protobuf.Timestamp\x12\x17\n\x0fsource_database\x18\x03 \x01(\tB\xd1\x01\n$com.google.spanner.admin.database.v1B\x0b\x42\x61\x63kupProtoP\x01ZHgoogle.golang.org/genproto/googleapis/spanner/admin/database/v1;database\xaa\x02&Google.Cloud.Spanner.Admin.Database.V1\xca\x02&Google\\Cloud\\Spanner\\Admin\\Database\\V1b\x06proto3' + ), + dependencies=[ + google_dot_api_dot_field__behavior__pb2.DESCRIPTOR, + google_dot_api_dot_resource__pb2.DESCRIPTOR, + google_dot_longrunning_dot_operations__pb2.DESCRIPTOR, + google_dot_protobuf_dot_field__mask__pb2.DESCRIPTOR, + google_dot_protobuf_dot_timestamp__pb2.DESCRIPTOR, + google_dot_cloud_dot_spanner_dot_admin_dot_database__v1_dot_proto_dot_common__pb2.DESCRIPTOR, + google_dot_api_dot_annotations__pb2.DESCRIPTOR, + ], +) + + +_BACKUP_STATE = _descriptor.EnumDescriptor( + name="State", + full_name="google.spanner.admin.database.v1.Backup.State", + filename=None, + file=DESCRIPTOR, + values=[ + _descriptor.EnumValueDescriptor( + name="STATE_UNSPECIFIED", + index=0, + number=0, + serialized_options=None, + type=None, + ), + _descriptor.EnumValueDescriptor( + name="CREATING", index=1, number=1, serialized_options=None, type=None + ), + _descriptor.EnumValueDescriptor( + name="READY", index=2, number=2, serialized_options=None, type=None + ), + ], + containing_type=None, + serialized_options=None, + serialized_start=623, + serialized_end=678, +) +_sym_db.RegisterEnumDescriptor(_BACKUP_STATE) + + +_BACKUP = _descriptor.Descriptor( + name="Backup", + full_name="google.spanner.admin.database.v1.Backup", + filename=None, + file=DESCRIPTOR, + containing_type=None, + fields=[ + _descriptor.FieldDescriptor( + name="database", + full_name="google.spanner.admin.database.v1.Backup.database", + index=0, + number=2, + type=9, + cpp_type=9, + label=1, + has_default_value=False, + default_value=_b("").decode("utf-8"), + message_type=None, + enum_type=None, + containing_type=None, + is_extension=False, + extension_scope=None, + serialized_options=None, + file=DESCRIPTOR, + ), + _descriptor.FieldDescriptor( + name="expire_time", + full_name="google.spanner.admin.database.v1.Backup.expire_time", + index=1, + number=3, + type=11, + cpp_type=10, + label=1, + has_default_value=False, + default_value=None, + message_type=None, + enum_type=None, + containing_type=None, + is_extension=False, + extension_scope=None, + serialized_options=None, + file=DESCRIPTOR, + ), + _descriptor.FieldDescriptor( + name="name", + full_name="google.spanner.admin.database.v1.Backup.name", + index=2, + number=1, + type=9, + cpp_type=9, + label=1, + has_default_value=False, + default_value=_b("").decode("utf-8"), + message_type=None, + enum_type=None, + containing_type=None, + is_extension=False, + extension_scope=None, + serialized_options=None, + file=DESCRIPTOR, + ), + _descriptor.FieldDescriptor( + name="create_time", + full_name="google.spanner.admin.database.v1.Backup.create_time", + index=3, + number=4, + type=11, + cpp_type=10, + label=1, + has_default_value=False, + default_value=None, + message_type=None, + enum_type=None, + containing_type=None, + is_extension=False, + extension_scope=None, + serialized_options=_b("\340A\003"), + file=DESCRIPTOR, + ), + _descriptor.FieldDescriptor( + name="size_bytes", + full_name="google.spanner.admin.database.v1.Backup.size_bytes", + index=4, + number=5, + type=3, + cpp_type=2, + label=1, + has_default_value=False, + default_value=0, + message_type=None, + enum_type=None, + containing_type=None, + is_extension=False, + extension_scope=None, + serialized_options=_b("\340A\003"), + file=DESCRIPTOR, + ), + _descriptor.FieldDescriptor( + name="state", + full_name="google.spanner.admin.database.v1.Backup.state", + index=5, + number=6, + type=14, + cpp_type=8, + label=1, + has_default_value=False, + default_value=0, + message_type=None, + enum_type=None, + containing_type=None, + is_extension=False, + extension_scope=None, + serialized_options=_b("\340A\003"), + file=DESCRIPTOR, + ), + _descriptor.FieldDescriptor( + name="referencing_databases", + full_name="google.spanner.admin.database.v1.Backup.referencing_databases", + index=6, + number=7, + type=9, + cpp_type=9, + label=3, + has_default_value=False, + default_value=[], + message_type=None, + enum_type=None, + containing_type=None, + is_extension=False, + extension_scope=None, + serialized_options=_b("\340A\003"), + file=DESCRIPTOR, + ), + ], + extensions=[], + nested_types=[], + enum_types=[_BACKUP_STATE], + serialized_options=_b( + "\352AY\n\035spanner.googleapis.com/Backup\0228projects/{project}/instances/{instance}/backups/{backup}" + ), + is_extendable=False, + syntax="proto3", + extension_ranges=[], + oneofs=[], + serialized_start=349, + serialized_end=772, +) + + +_CREATEBACKUPREQUEST = _descriptor.Descriptor( + name="CreateBackupRequest", + full_name="google.spanner.admin.database.v1.CreateBackupRequest", + filename=None, + file=DESCRIPTOR, + containing_type=None, + fields=[ + _descriptor.FieldDescriptor( + name="parent", + full_name="google.spanner.admin.database.v1.CreateBackupRequest.parent", + index=0, + number=1, + type=9, + cpp_type=9, + label=1, + has_default_value=False, + default_value=_b("").decode("utf-8"), + message_type=None, + enum_type=None, + containing_type=None, + is_extension=False, + extension_scope=None, + serialized_options=_b( + "\340A\002\372A!\n\037spanner.googleapis.com/Instance" + ), + file=DESCRIPTOR, + ), + _descriptor.FieldDescriptor( + name="backup_id", + full_name="google.spanner.admin.database.v1.CreateBackupRequest.backup_id", + index=1, + number=2, + type=9, + cpp_type=9, + label=1, + has_default_value=False, + default_value=_b("").decode("utf-8"), + message_type=None, + enum_type=None, + containing_type=None, + is_extension=False, + extension_scope=None, + serialized_options=_b("\340A\002"), + file=DESCRIPTOR, + ), + _descriptor.FieldDescriptor( + name="backup", + full_name="google.spanner.admin.database.v1.CreateBackupRequest.backup", + index=2, + number=3, + type=11, + cpp_type=10, + label=1, + has_default_value=False, + default_value=None, + message_type=None, + enum_type=None, + containing_type=None, + is_extension=False, + extension_scope=None, + serialized_options=_b("\340A\002"), + file=DESCRIPTOR, + ), + ], + extensions=[], + nested_types=[], + enum_types=[], + serialized_options=None, + is_extendable=False, + syntax="proto3", + extension_ranges=[], + oneofs=[], + serialized_start=775, + serialized_end=940, +) + + +_CREATEBACKUPMETADATA = _descriptor.Descriptor( + name="CreateBackupMetadata", + full_name="google.spanner.admin.database.v1.CreateBackupMetadata", + filename=None, + file=DESCRIPTOR, + containing_type=None, + fields=[ + _descriptor.FieldDescriptor( + name="name", + full_name="google.spanner.admin.database.v1.CreateBackupMetadata.name", + index=0, + number=1, + type=9, + cpp_type=9, + label=1, + has_default_value=False, + default_value=_b("").decode("utf-8"), + message_type=None, + enum_type=None, + containing_type=None, + is_extension=False, + extension_scope=None, + serialized_options=None, + file=DESCRIPTOR, + ), + _descriptor.FieldDescriptor( + name="database", + full_name="google.spanner.admin.database.v1.CreateBackupMetadata.database", + index=1, + number=2, + type=9, + cpp_type=9, + label=1, + has_default_value=False, + default_value=_b("").decode("utf-8"), + message_type=None, + enum_type=None, + containing_type=None, + is_extension=False, + extension_scope=None, + serialized_options=None, + file=DESCRIPTOR, + ), + _descriptor.FieldDescriptor( + name="progress", + full_name="google.spanner.admin.database.v1.CreateBackupMetadata.progress", + index=2, + number=3, + type=11, + cpp_type=10, + label=1, + has_default_value=False, + default_value=None, + message_type=None, + enum_type=None, + containing_type=None, + is_extension=False, + extension_scope=None, + serialized_options=None, + file=DESCRIPTOR, + ), + _descriptor.FieldDescriptor( + name="cancel_time", + full_name="google.spanner.admin.database.v1.CreateBackupMetadata.cancel_time", + index=3, + number=4, + type=11, + cpp_type=10, + label=1, + has_default_value=False, + default_value=None, + message_type=None, + enum_type=None, + containing_type=None, + is_extension=False, + extension_scope=None, + serialized_options=None, + file=DESCRIPTOR, + ), + ], + extensions=[], + nested_types=[], + enum_types=[], + serialized_options=None, + is_extendable=False, + syntax="proto3", + extension_ranges=[], + oneofs=[], + serialized_start=943, + serialized_end=1117, +) + + +_UPDATEBACKUPREQUEST = _descriptor.Descriptor( + name="UpdateBackupRequest", + full_name="google.spanner.admin.database.v1.UpdateBackupRequest", + filename=None, + file=DESCRIPTOR, + containing_type=None, + fields=[ + _descriptor.FieldDescriptor( + name="backup", + full_name="google.spanner.admin.database.v1.UpdateBackupRequest.backup", + index=0, + number=1, + type=11, + cpp_type=10, + label=1, + has_default_value=False, + default_value=None, + message_type=None, + enum_type=None, + containing_type=None, + is_extension=False, + extension_scope=None, + serialized_options=_b("\340A\002"), + file=DESCRIPTOR, + ), + _descriptor.FieldDescriptor( + name="update_mask", + full_name="google.spanner.admin.database.v1.UpdateBackupRequest.update_mask", + index=1, + number=2, + type=11, + cpp_type=10, + label=1, + has_default_value=False, + default_value=None, + message_type=None, + enum_type=None, + containing_type=None, + is_extension=False, + extension_scope=None, + serialized_options=_b("\340A\002"), + file=DESCRIPTOR, + ), + ], + extensions=[], + nested_types=[], + enum_types=[], + serialized_options=None, + is_extendable=False, + syntax="proto3", + extension_ranges=[], + oneofs=[], + serialized_start=1120, + serialized_end=1258, +) + + +_GETBACKUPREQUEST = _descriptor.Descriptor( + name="GetBackupRequest", + full_name="google.spanner.admin.database.v1.GetBackupRequest", + filename=None, + file=DESCRIPTOR, + containing_type=None, + fields=[ + _descriptor.FieldDescriptor( + name="name", + full_name="google.spanner.admin.database.v1.GetBackupRequest.name", + index=0, + number=1, + type=9, + cpp_type=9, + label=1, + has_default_value=False, + default_value=_b("").decode("utf-8"), + message_type=None, + enum_type=None, + containing_type=None, + is_extension=False, + extension_scope=None, + serialized_options=_b( + "\340A\002\372A\037\n\035spanner.googleapis.com/Backup" + ), + file=DESCRIPTOR, + ) + ], + extensions=[], + nested_types=[], + enum_types=[], + serialized_options=None, + is_extendable=False, + syntax="proto3", + extension_ranges=[], + oneofs=[], + serialized_start=1260, + serialized_end=1331, +) + + +_DELETEBACKUPREQUEST = _descriptor.Descriptor( + name="DeleteBackupRequest", + full_name="google.spanner.admin.database.v1.DeleteBackupRequest", + filename=None, + file=DESCRIPTOR, + containing_type=None, + fields=[ + _descriptor.FieldDescriptor( + name="name", + full_name="google.spanner.admin.database.v1.DeleteBackupRequest.name", + index=0, + number=1, + type=9, + cpp_type=9, + label=1, + has_default_value=False, + default_value=_b("").decode("utf-8"), + message_type=None, + enum_type=None, + containing_type=None, + is_extension=False, + extension_scope=None, + serialized_options=_b( + "\340A\002\372A\037\n\035spanner.googleapis.com/Backup" + ), + file=DESCRIPTOR, + ) + ], + extensions=[], + nested_types=[], + enum_types=[], + serialized_options=None, + is_extendable=False, + syntax="proto3", + extension_ranges=[], + oneofs=[], + serialized_start=1333, + serialized_end=1407, +) + + +_LISTBACKUPSREQUEST = _descriptor.Descriptor( + name="ListBackupsRequest", + full_name="google.spanner.admin.database.v1.ListBackupsRequest", + filename=None, + file=DESCRIPTOR, + containing_type=None, + fields=[ + _descriptor.FieldDescriptor( + name="parent", + full_name="google.spanner.admin.database.v1.ListBackupsRequest.parent", + index=0, + number=1, + type=9, + cpp_type=9, + label=1, + has_default_value=False, + default_value=_b("").decode("utf-8"), + message_type=None, + enum_type=None, + containing_type=None, + is_extension=False, + extension_scope=None, + serialized_options=_b( + "\340A\002\372A!\n\037spanner.googleapis.com/Instance" + ), + file=DESCRIPTOR, + ), + _descriptor.FieldDescriptor( + name="filter", + full_name="google.spanner.admin.database.v1.ListBackupsRequest.filter", + index=1, + number=2, + type=9, + cpp_type=9, + label=1, + has_default_value=False, + default_value=_b("").decode("utf-8"), + message_type=None, + enum_type=None, + containing_type=None, + is_extension=False, + extension_scope=None, + serialized_options=None, + file=DESCRIPTOR, + ), + _descriptor.FieldDescriptor( + name="page_size", + full_name="google.spanner.admin.database.v1.ListBackupsRequest.page_size", + index=2, + number=3, + type=5, + cpp_type=1, + label=1, + has_default_value=False, + default_value=0, + message_type=None, + enum_type=None, + containing_type=None, + is_extension=False, + extension_scope=None, + serialized_options=None, + file=DESCRIPTOR, + ), + _descriptor.FieldDescriptor( + name="page_token", + full_name="google.spanner.admin.database.v1.ListBackupsRequest.page_token", + index=3, + number=4, + type=9, + cpp_type=9, + label=1, + has_default_value=False, + default_value=_b("").decode("utf-8"), + message_type=None, + enum_type=None, + containing_type=None, + is_extension=False, + extension_scope=None, + serialized_options=None, + file=DESCRIPTOR, + ), + ], + extensions=[], + nested_types=[], + enum_types=[], + serialized_options=None, + is_extendable=False, + syntax="proto3", + extension_ranges=[], + oneofs=[], + serialized_start=1410, + serialized_end=1542, +) + + +_LISTBACKUPSRESPONSE = _descriptor.Descriptor( + name="ListBackupsResponse", + full_name="google.spanner.admin.database.v1.ListBackupsResponse", + filename=None, + file=DESCRIPTOR, + containing_type=None, + fields=[ + _descriptor.FieldDescriptor( + name="backups", + full_name="google.spanner.admin.database.v1.ListBackupsResponse.backups", + index=0, + number=1, + type=11, + cpp_type=10, + label=3, + has_default_value=False, + default_value=[], + message_type=None, + enum_type=None, + containing_type=None, + is_extension=False, + extension_scope=None, + serialized_options=None, + file=DESCRIPTOR, + ), + _descriptor.FieldDescriptor( + name="next_page_token", + full_name="google.spanner.admin.database.v1.ListBackupsResponse.next_page_token", + index=1, + number=2, + type=9, + cpp_type=9, + label=1, + has_default_value=False, + default_value=_b("").decode("utf-8"), + message_type=None, + enum_type=None, + containing_type=None, + is_extension=False, + extension_scope=None, + serialized_options=None, + file=DESCRIPTOR, + ), + ], + extensions=[], + nested_types=[], + enum_types=[], + serialized_options=None, + is_extendable=False, + syntax="proto3", + extension_ranges=[], + oneofs=[], + serialized_start=1544, + serialized_end=1649, +) + + +_LISTBACKUPOPERATIONSREQUEST = _descriptor.Descriptor( + name="ListBackupOperationsRequest", + full_name="google.spanner.admin.database.v1.ListBackupOperationsRequest", + filename=None, + file=DESCRIPTOR, + containing_type=None, + fields=[ + _descriptor.FieldDescriptor( + name="parent", + full_name="google.spanner.admin.database.v1.ListBackupOperationsRequest.parent", + index=0, + number=1, + type=9, + cpp_type=9, + label=1, + has_default_value=False, + default_value=_b("").decode("utf-8"), + message_type=None, + enum_type=None, + containing_type=None, + is_extension=False, + extension_scope=None, + serialized_options=_b( + "\340A\002\372A!\n\037spanner.googleapis.com/Instance" + ), + file=DESCRIPTOR, + ), + _descriptor.FieldDescriptor( + name="filter", + full_name="google.spanner.admin.database.v1.ListBackupOperationsRequest.filter", + index=1, + number=2, + type=9, + cpp_type=9, + label=1, + has_default_value=False, + default_value=_b("").decode("utf-8"), + message_type=None, + enum_type=None, + containing_type=None, + is_extension=False, + extension_scope=None, + serialized_options=None, + file=DESCRIPTOR, + ), + _descriptor.FieldDescriptor( + name="page_size", + full_name="google.spanner.admin.database.v1.ListBackupOperationsRequest.page_size", + index=2, + number=3, + type=5, + cpp_type=1, + label=1, + has_default_value=False, + default_value=0, + message_type=None, + enum_type=None, + containing_type=None, + is_extension=False, + extension_scope=None, + serialized_options=None, + file=DESCRIPTOR, + ), + _descriptor.FieldDescriptor( + name="page_token", + full_name="google.spanner.admin.database.v1.ListBackupOperationsRequest.page_token", + index=3, + number=4, + type=9, + cpp_type=9, + label=1, + has_default_value=False, + default_value=_b("").decode("utf-8"), + message_type=None, + enum_type=None, + containing_type=None, + is_extension=False, + extension_scope=None, + serialized_options=None, + file=DESCRIPTOR, + ), + ], + extensions=[], + nested_types=[], + enum_types=[], + serialized_options=None, + is_extendable=False, + syntax="proto3", + extension_ranges=[], + oneofs=[], + serialized_start=1652, + serialized_end=1793, +) + + +_LISTBACKUPOPERATIONSRESPONSE = _descriptor.Descriptor( + name="ListBackupOperationsResponse", + full_name="google.spanner.admin.database.v1.ListBackupOperationsResponse", + filename=None, + file=DESCRIPTOR, + containing_type=None, + fields=[ + _descriptor.FieldDescriptor( + name="operations", + full_name="google.spanner.admin.database.v1.ListBackupOperationsResponse.operations", + index=0, + number=1, + type=11, + cpp_type=10, + label=3, + has_default_value=False, + default_value=[], + message_type=None, + enum_type=None, + containing_type=None, + is_extension=False, + extension_scope=None, + serialized_options=None, + file=DESCRIPTOR, + ), + _descriptor.FieldDescriptor( + name="next_page_token", + full_name="google.spanner.admin.database.v1.ListBackupOperationsResponse.next_page_token", + index=1, + number=2, + type=9, + cpp_type=9, + label=1, + has_default_value=False, + default_value=_b("").decode("utf-8"), + message_type=None, + enum_type=None, + containing_type=None, + is_extension=False, + extension_scope=None, + serialized_options=None, + file=DESCRIPTOR, + ), + ], + extensions=[], + nested_types=[], + enum_types=[], + serialized_options=None, + is_extendable=False, + syntax="proto3", + extension_ranges=[], + oneofs=[], + serialized_start=1795, + serialized_end=1901, +) + + +_BACKUPINFO = _descriptor.Descriptor( + name="BackupInfo", + full_name="google.spanner.admin.database.v1.BackupInfo", + filename=None, + file=DESCRIPTOR, + containing_type=None, + fields=[ + _descriptor.FieldDescriptor( + name="backup", + full_name="google.spanner.admin.database.v1.BackupInfo.backup", + index=0, + number=1, + type=9, + cpp_type=9, + label=1, + has_default_value=False, + default_value=_b("").decode("utf-8"), + message_type=None, + enum_type=None, + containing_type=None, + is_extension=False, + extension_scope=None, + serialized_options=None, + file=DESCRIPTOR, + ), + _descriptor.FieldDescriptor( + name="create_time", + full_name="google.spanner.admin.database.v1.BackupInfo.create_time", + index=1, + number=2, + type=11, + cpp_type=10, + label=1, + has_default_value=False, + default_value=None, + message_type=None, + enum_type=None, + containing_type=None, + is_extension=False, + extension_scope=None, + serialized_options=None, + file=DESCRIPTOR, + ), + _descriptor.FieldDescriptor( + name="source_database", + full_name="google.spanner.admin.database.v1.BackupInfo.source_database", + index=2, + number=3, + type=9, + cpp_type=9, + label=1, + has_default_value=False, + default_value=_b("").decode("utf-8"), + message_type=None, + enum_type=None, + containing_type=None, + is_extension=False, + extension_scope=None, + serialized_options=None, + file=DESCRIPTOR, + ), + ], + extensions=[], + nested_types=[], + enum_types=[], + serialized_options=None, + is_extendable=False, + syntax="proto3", + extension_ranges=[], + oneofs=[], + serialized_start=1903, + serialized_end=2005, +) + +_BACKUP.fields_by_name[ + "expire_time" +].message_type = google_dot_protobuf_dot_timestamp__pb2._TIMESTAMP +_BACKUP.fields_by_name[ + "create_time" +].message_type = google_dot_protobuf_dot_timestamp__pb2._TIMESTAMP +_BACKUP.fields_by_name["state"].enum_type = _BACKUP_STATE +_BACKUP_STATE.containing_type = _BACKUP +_CREATEBACKUPREQUEST.fields_by_name["backup"].message_type = _BACKUP +_CREATEBACKUPMETADATA.fields_by_name[ + "progress" +].message_type = ( + google_dot_cloud_dot_spanner_dot_admin_dot_database__v1_dot_proto_dot_common__pb2._OPERATIONPROGRESS +) +_CREATEBACKUPMETADATA.fields_by_name[ + "cancel_time" +].message_type = google_dot_protobuf_dot_timestamp__pb2._TIMESTAMP +_UPDATEBACKUPREQUEST.fields_by_name["backup"].message_type = _BACKUP +_UPDATEBACKUPREQUEST.fields_by_name[ + "update_mask" +].message_type = google_dot_protobuf_dot_field__mask__pb2._FIELDMASK +_LISTBACKUPSRESPONSE.fields_by_name["backups"].message_type = _BACKUP +_LISTBACKUPOPERATIONSRESPONSE.fields_by_name[ + "operations" +].message_type = google_dot_longrunning_dot_operations__pb2._OPERATION +_BACKUPINFO.fields_by_name[ + "create_time" +].message_type = google_dot_protobuf_dot_timestamp__pb2._TIMESTAMP +DESCRIPTOR.message_types_by_name["Backup"] = _BACKUP +DESCRIPTOR.message_types_by_name["CreateBackupRequest"] = _CREATEBACKUPREQUEST +DESCRIPTOR.message_types_by_name["CreateBackupMetadata"] = _CREATEBACKUPMETADATA +DESCRIPTOR.message_types_by_name["UpdateBackupRequest"] = _UPDATEBACKUPREQUEST +DESCRIPTOR.message_types_by_name["GetBackupRequest"] = _GETBACKUPREQUEST +DESCRIPTOR.message_types_by_name["DeleteBackupRequest"] = _DELETEBACKUPREQUEST +DESCRIPTOR.message_types_by_name["ListBackupsRequest"] = _LISTBACKUPSREQUEST +DESCRIPTOR.message_types_by_name["ListBackupsResponse"] = _LISTBACKUPSRESPONSE +DESCRIPTOR.message_types_by_name[ + "ListBackupOperationsRequest" +] = _LISTBACKUPOPERATIONSREQUEST +DESCRIPTOR.message_types_by_name[ + "ListBackupOperationsResponse" +] = _LISTBACKUPOPERATIONSRESPONSE +DESCRIPTOR.message_types_by_name["BackupInfo"] = _BACKUPINFO +_sym_db.RegisterFileDescriptor(DESCRIPTOR) + +Backup = _reflection.GeneratedProtocolMessageType( + "Backup", + (_message.Message,), + dict( + DESCRIPTOR=_BACKUP, + __module__="google.cloud.spanner.admin.database_v1.proto.backup_pb2", + __doc__="""A backup of a Cloud Spanner database. + + + Attributes: + database: + Required for the [CreateBackup][google.spanner.admin.database. + v1.DatabaseAdmin.CreateBackup] operation. Name of the database + from which this backup was created. This needs to be in the + same instance as the backup. Values are of the form ``projects + //instances//databases/``. + expire_time: + Required for the [CreateBackup][google.spanner.admin.database. + v1.DatabaseAdmin.CreateBackup] operation. The expiration time + of the backup, with microseconds granularity that must be at + least 6 hours and at most 366 days from the time the + CreateBackup request is processed. Once the ``expire_time`` + has passed, the backup is eligible to be automatically deleted + by Cloud Spanner to free the resources used by the backup. + name: + Output only for the [CreateBackup][google.spanner.admin.databa + se.v1.DatabaseAdmin.CreateBackup] operation. Required for the + [UpdateBackup][google.spanner.admin.database.v1.DatabaseAdmin. + UpdateBackup] operation. A globally unique identifier for the + backup which cannot be changed. Values are of the form ``proje + cts//instances//backups/[a-z][a-z0-9_\-]*[a + -z0-9]`` The final segment of the name must be between 2 and + 60 characters in length. The backup is stored in the + location(s) specified in the instance configuration of the + instance containing the backup, identified by the prefix of + the backup name of the form + ``projects//instances/``. + create_time: + Output only. The backup will contain an externally consistent + copy of the database at the timestamp specified by + ``create_time``. ``create_time`` is approximately the time the + [CreateBackup][google.spanner.admin.database.v1.DatabaseAdmin. + CreateBackup] request is received. + size_bytes: + Output only. Size of the backup in bytes. + state: + Output only. The current state of the backup. + referencing_databases: + Output only. The names of the restored databases that + reference the backup. The database names are of the form ``pro + jects//instances//databases/``. + Referencing databases may exist in different instances. The + existence of any referencing database prevents the backup from + being deleted. When a restored database from the backup enters + the ``READY`` state, the reference to the backup is removed. + """, + # @@protoc_insertion_point(class_scope:google.spanner.admin.database.v1.Backup) + ), +) +_sym_db.RegisterMessage(Backup) + +CreateBackupRequest = _reflection.GeneratedProtocolMessageType( + "CreateBackupRequest", + (_message.Message,), + dict( + DESCRIPTOR=_CREATEBACKUPREQUEST, + __module__="google.cloud.spanner.admin.database_v1.proto.backup_pb2", + __doc__="""The request for + [CreateBackup][google.spanner.admin.database.v1.DatabaseAdmin.CreateBackup]. + + + Attributes: + parent: + Required. The name of the instance in which the backup will be + created. This must be the same instance that contains the + database the backup will be created from. The backup will be + stored in the location(s) specified in the instance + configuration of this instance. Values are of the form + ``projects//instances/``. + backup_id: + Required. The id of the backup to be created. The + ``backup_id`` appended to ``parent`` forms the full backup + name of the form ``projects//instances//bac + kups/``. + backup: + Required. The backup to create. + """, + # @@protoc_insertion_point(class_scope:google.spanner.admin.database.v1.CreateBackupRequest) + ), +) +_sym_db.RegisterMessage(CreateBackupRequest) + +CreateBackupMetadata = _reflection.GeneratedProtocolMessageType( + "CreateBackupMetadata", + (_message.Message,), + dict( + DESCRIPTOR=_CREATEBACKUPMETADATA, + __module__="google.cloud.spanner.admin.database_v1.proto.backup_pb2", + __doc__="""Metadata type for the operation returned by + [CreateBackup][google.spanner.admin.database.v1.DatabaseAdmin.CreateBackup]. + + + Attributes: + name: + The name of the backup being created. + database: + The name of the database the backup is created from. + progress: + The progress of the [CreateBackup][google.spanner.admin.databa + se.v1.DatabaseAdmin.CreateBackup] operation. + cancel_time: + The time at which cancellation of this operation was received. + [Operations.CancelOperation][google.longrunning.Operations.Can + celOperation] starts asynchronous cancellation on a long- + running operation. The server makes a best effort to cancel + the operation, but success is not guaranteed. Clients can use + [Operations.GetOperation][google.longrunning.Operations.GetOpe + ration] or other methods to check whether the cancellation + succeeded or whether the operation completed despite + cancellation. On successful cancellation, the operation is not + deleted; instead, it becomes an operation with an + [Operation.error][] value with a + [google.rpc.Status.code][google.rpc.Status.code] of 1, + corresponding to ``Code.CANCELLED``. + """, + # @@protoc_insertion_point(class_scope:google.spanner.admin.database.v1.CreateBackupMetadata) + ), +) +_sym_db.RegisterMessage(CreateBackupMetadata) + +UpdateBackupRequest = _reflection.GeneratedProtocolMessageType( + "UpdateBackupRequest", + (_message.Message,), + dict( + DESCRIPTOR=_UPDATEBACKUPREQUEST, + __module__="google.cloud.spanner.admin.database_v1.proto.backup_pb2", + __doc__="""The request for + [UpdateBackup][google.spanner.admin.database.v1.DatabaseAdmin.UpdateBackup]. + + + Attributes: + backup: + Required. The backup to update. ``backup.name``, and the + fields to be updated as specified by ``update_mask`` are + required. Other fields are ignored. Update is only supported + for the following fields: \* ``backup.expire_time``. + update_mask: + Required. A mask specifying which fields (e.g. + ``expire_time``) in the Backup resource should be updated. + This mask is relative to the Backup resource, not to the + request message. The field mask must always be specified; this + prevents any future fields from being erased accidentally by + clients that do not know about them. + """, + # @@protoc_insertion_point(class_scope:google.spanner.admin.database.v1.UpdateBackupRequest) + ), +) +_sym_db.RegisterMessage(UpdateBackupRequest) + +GetBackupRequest = _reflection.GeneratedProtocolMessageType( + "GetBackupRequest", + (_message.Message,), + dict( + DESCRIPTOR=_GETBACKUPREQUEST, + __module__="google.cloud.spanner.admin.database_v1.proto.backup_pb2", + __doc__="""The request for + [GetBackup][google.spanner.admin.database.v1.DatabaseAdmin.GetBackup]. + + + Attributes: + name: + Required. Name of the backup. Values are of the form + ``projects//instances//backups/``. + """, + # @@protoc_insertion_point(class_scope:google.spanner.admin.database.v1.GetBackupRequest) + ), +) +_sym_db.RegisterMessage(GetBackupRequest) + +DeleteBackupRequest = _reflection.GeneratedProtocolMessageType( + "DeleteBackupRequest", + (_message.Message,), + dict( + DESCRIPTOR=_DELETEBACKUPREQUEST, + __module__="google.cloud.spanner.admin.database_v1.proto.backup_pb2", + __doc__="""The request for + [DeleteBackup][google.spanner.admin.database.v1.DatabaseAdmin.DeleteBackup]. + + + Attributes: + name: + Required. Name of the backup to delete. Values are of the form + ``projects//instances//backups/``. + """, + # @@protoc_insertion_point(class_scope:google.spanner.admin.database.v1.DeleteBackupRequest) + ), +) +_sym_db.RegisterMessage(DeleteBackupRequest) + +ListBackupsRequest = _reflection.GeneratedProtocolMessageType( + "ListBackupsRequest", + (_message.Message,), + dict( + DESCRIPTOR=_LISTBACKUPSREQUEST, + __module__="google.cloud.spanner.admin.database_v1.proto.backup_pb2", + __doc__="""The request for + [ListBackups][google.spanner.admin.database.v1.DatabaseAdmin.ListBackups]. + + + Attributes: + parent: + Required. The instance to list backups from. Values are of the + form ``projects//instances/``. + filter: + An expression that filters the list of returned backups. A + filter expression consists of a field name, a comparison + operator, and a value for filtering. The value must be a + string, a number, or a boolean. The comparison operator must + be one of: ``<``, ``>``, ``<=``, ``>=``, ``!=``, ``=``, or + ``:``. Colon ``:`` is the contains operator. Filter rules are + not case sensitive. The following fields in the + [Backup][google.spanner.admin.database.v1.Backup] are eligible + for filtering: - ``name`` - ``database`` - ``state`` - + ``create_time`` (and values are of the format YYYY-MM- + DDTHH:MM:SSZ) - ``expire_time`` (and values are of the format + YYYY-MM-DDTHH:MM:SSZ) - ``size_bytes`` You can combine + multiple expressions by enclosing each expression in + parentheses. By default, expressions are combined with AND + logic, but you can specify AND, OR, and NOT logic explicitly. + Here are a few examples: - ``name:Howl`` - The backup's name + contains the string "howl". - ``database:prod`` - The + database's name contains the string "prod". - + ``state:CREATING`` - The backup is pending creation. - + ``state:READY`` - The backup is fully created and ready for + use. - ``(name:howl) AND (create_time < + \"2018-03-28T14:50:00Z\")`` - The backup name contains the + string "howl" and ``create_time`` of the backup is before + 2018-03-28T14:50:00Z. - ``expire_time < + \"2018-03-28T14:50:00Z\"`` - The backup ``expire_time`` is + before 2018-03-28T14:50:00Z. - ``size_bytes > 10000000000`` - + The backup's size is greater than 10GB + page_size: + Number of backups to be returned in the response. If 0 or + less, defaults to the server's maximum allowed page size. + page_token: + If non-empty, ``page_token`` should contain a [next\_page\_tok + en][google.spanner.admin.database.v1.ListBackupsResponse.next\ + _page\_token] from a previous [ListBackupsResponse][google.spa + nner.admin.database.v1.ListBackupsResponse] to the same + ``parent`` and with the same ``filter``. + """, + # @@protoc_insertion_point(class_scope:google.spanner.admin.database.v1.ListBackupsRequest) + ), +) +_sym_db.RegisterMessage(ListBackupsRequest) + +ListBackupsResponse = _reflection.GeneratedProtocolMessageType( + "ListBackupsResponse", + (_message.Message,), + dict( + DESCRIPTOR=_LISTBACKUPSRESPONSE, + __module__="google.cloud.spanner.admin.database_v1.proto.backup_pb2", + __doc__="""The response for + [ListBackups][google.spanner.admin.database.v1.DatabaseAdmin.ListBackups]. + + + Attributes: + backups: + The list of matching backups. Backups returned are ordered by + ``create_time`` in descending order, starting from the most + recent ``create_time``. + next_page_token: + \ ``next_page_token`` can be sent in a subsequent [ListBackups + ][google.spanner.admin.database.v1.DatabaseAdmin.ListBackups] + call to fetch more of the matching backups. + """, + # @@protoc_insertion_point(class_scope:google.spanner.admin.database.v1.ListBackupsResponse) + ), +) +_sym_db.RegisterMessage(ListBackupsResponse) + +ListBackupOperationsRequest = _reflection.GeneratedProtocolMessageType( + "ListBackupOperationsRequest", + (_message.Message,), + dict( + DESCRIPTOR=_LISTBACKUPOPERATIONSREQUEST, + __module__="google.cloud.spanner.admin.database_v1.proto.backup_pb2", + __doc__="""The request for + [ListBackupOperations][google.spanner.admin.database.v1.DatabaseAdmin.ListBackupOperations]. + + + Attributes: + parent: + Required. The instance of the backup operations. Values are of + the form ``projects//instances/``. + filter: + An expression that filters the list of returned backup + operations. A filter expression consists of a field name, a + comparison operator, and a value for filtering. The value must + be a string, a number, or a boolean. The comparison operator + must be one of: ``<``, ``>``, ``<=``, ``>=``, ``!=``, ``=``, + or ``:``. Colon ``:`` is the contains operator. Filter rules + are not case sensitive. The following fields in the + [operation][google.longrunning.Operation] are eligible for + filtering: - ``name`` - The name of the long-running + operation - ``done`` - False if the operation is in progress, + else true. - ``metadata.@type`` - the type of metadata. For + example, the type string for [CreateBackupMetadata][goog + le.spanner.admin.database.v1.CreateBackupMetadata] is `` + type.googleapis.com/google.spanner.admin.database.v1.CreateBac + kupMetadata``. - ``metadata.`` - any field in + metadata.value. - ``error`` - Error associated with the long- + running operation. - ``response.@type`` - the type of + response. - ``response.`` - any field in + response.value. You can combine multiple expressions by + enclosing each expression in parentheses. By default, + expressions are combined with AND logic, but you can specify + AND, OR, and NOT logic explicitly. Here are a few examples: + - ``done:true`` - The operation is complete. - + ``metadata.database:prod`` - The database the backup was taken + from has a name containing the string "prod". - ``(metadat + a.@type=type.googleapis.com/google.spanner.admin.database.v1.C + reateBackupMetadata) AND`` ``(metadata.name:howl) AND`` + ``(metadata.progress.start_time < \"2018-03-28T14:50:00Z\") + AND`` ``(error:*)`` - Returns operations where: - The + operation's metadata type is [CreateBackupMetadata][goog + le.spanner.admin.database.v1.CreateBackupMetadata]. - The + backup name contains the string "howl". - The operation + started before 2018-03-28T14:50:00Z. - The operation + resulted in an error. + page_size: + Number of operations to be returned in the response. If 0 or + less, defaults to the server's maximum allowed page size. + page_token: + If non-empty, ``page_token`` should contain a [next\_page\_tok + en][google.spanner.admin.database.v1.ListBackupOperationsRespo + nse.next\_page\_token] from a previous [ListBackupOperationsRe + sponse][google.spanner.admin.database.v1.ListBackupOperationsR + esponse] to the same ``parent`` and with the same ``filter``. + """, + # @@protoc_insertion_point(class_scope:google.spanner.admin.database.v1.ListBackupOperationsRequest) + ), +) +_sym_db.RegisterMessage(ListBackupOperationsRequest) + +ListBackupOperationsResponse = _reflection.GeneratedProtocolMessageType( + "ListBackupOperationsResponse", + (_message.Message,), + dict( + DESCRIPTOR=_LISTBACKUPOPERATIONSRESPONSE, + __module__="google.cloud.spanner.admin.database_v1.proto.backup_pb2", + __doc__="""The response for + [ListBackupOperations][google.spanner.admin.database.v1.DatabaseAdmin.ListBackupOperations]. + + + Attributes: + operations: + The list of matching backup [long-running + operations][google.longrunning.Operation]. Each operation's + name will be prefixed by the backup's name and the operation's + [metadata][google.longrunning.Operation.metadata] will be of + type [CreateBackupMetadata][google.spanner.admin.database.v1.C + reateBackupMetadata]. Operations returned include those that + are pending or have completed/failed/canceled within the last + 7 days. Operations returned are ordered by + ``operation.metadata.value.progress.start_time`` in descending + order starting from the most recently started operation. + next_page_token: + \ ``next_page_token`` can be sent in a subsequent [ListBackupO + perations][google.spanner.admin.database.v1.DatabaseAdmin.List + BackupOperations] call to fetch more of the matching metadata. + """, + # @@protoc_insertion_point(class_scope:google.spanner.admin.database.v1.ListBackupOperationsResponse) + ), +) +_sym_db.RegisterMessage(ListBackupOperationsResponse) + +BackupInfo = _reflection.GeneratedProtocolMessageType( + "BackupInfo", + (_message.Message,), + dict( + DESCRIPTOR=_BACKUPINFO, + __module__="google.cloud.spanner.admin.database_v1.proto.backup_pb2", + __doc__="""Information about a backup. + + + Attributes: + backup: + Name of the backup. + create_time: + The backup contains an externally consistent copy of + ``source_database`` at the timestamp specified by + ``create_time``. + source_database: + Name of the database the backup was created from. + """, + # @@protoc_insertion_point(class_scope:google.spanner.admin.database.v1.BackupInfo) + ), +) +_sym_db.RegisterMessage(BackupInfo) + + +DESCRIPTOR._options = None +_BACKUP.fields_by_name["create_time"]._options = None +_BACKUP.fields_by_name["size_bytes"]._options = None +_BACKUP.fields_by_name["state"]._options = None +_BACKUP.fields_by_name["referencing_databases"]._options = None +_BACKUP._options = None +_CREATEBACKUPREQUEST.fields_by_name["parent"]._options = None +_CREATEBACKUPREQUEST.fields_by_name["backup_id"]._options = None +_CREATEBACKUPREQUEST.fields_by_name["backup"]._options = None +_UPDATEBACKUPREQUEST.fields_by_name["backup"]._options = None +_UPDATEBACKUPREQUEST.fields_by_name["update_mask"]._options = None +_GETBACKUPREQUEST.fields_by_name["name"]._options = None +_DELETEBACKUPREQUEST.fields_by_name["name"]._options = None +_LISTBACKUPSREQUEST.fields_by_name["parent"]._options = None +_LISTBACKUPOPERATIONSREQUEST.fields_by_name["parent"]._options = None +# @@protoc_insertion_point(module_scope) diff --git a/google/cloud/spanner_admin_database_v1/proto/backup_pb2_grpc.py b/google/cloud/spanner_admin_database_v1/proto/backup_pb2_grpc.py new file mode 100644 index 0000000000..07cb78fe03 --- /dev/null +++ b/google/cloud/spanner_admin_database_v1/proto/backup_pb2_grpc.py @@ -0,0 +1,2 @@ +# Generated by the gRPC Python protocol compiler plugin. DO NOT EDIT! +import grpc diff --git a/google/cloud/spanner_admin_database_v1/proto/common.proto b/google/cloud/spanner_admin_database_v1/proto/common.proto new file mode 100644 index 0000000000..4914cb8ac7 --- /dev/null +++ b/google/cloud/spanner_admin_database_v1/proto/common.proto @@ -0,0 +1,43 @@ +// Copyright 2020 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.spanner.admin.database.v1; + +import "google/api/field_behavior.proto"; +import "google/protobuf/timestamp.proto"; +import "google/api/annotations.proto"; + +option csharp_namespace = "Google.Cloud.Spanner.Admin.Database.V1"; +option go_package = "google.golang.org/genproto/googleapis/spanner/admin/database/v1;database"; +option java_multiple_files = true; +option java_outer_classname = "CommonProto"; +option java_package = "com.google.spanner.admin.database.v1"; +option php_namespace = "Google\\Cloud\\Spanner\\Admin\\Database\\V1"; + +// Encapsulates progress related information for a Cloud Spanner long +// running operation. +message OperationProgress { + // Percent completion of the operation. + // Values are between 0 and 100 inclusive. + int32 progress_percent = 1; + + // Time the request was received. + google.protobuf.Timestamp start_time = 2; + + // If set, the time at which this operation failed or was completed + // successfully. + google.protobuf.Timestamp end_time = 3; +} diff --git a/google/cloud/spanner_admin_database_v1/proto/common_pb2.py b/google/cloud/spanner_admin_database_v1/proto/common_pb2.py new file mode 100644 index 0000000000..6dc9895d39 --- /dev/null +++ b/google/cloud/spanner_admin_database_v1/proto/common_pb2.py @@ -0,0 +1,151 @@ +# -*- coding: utf-8 -*- +# Generated by the protocol buffer compiler. DO NOT EDIT! +# source: google/cloud/spanner/admin/database_v1/proto/common.proto + +import sys + +_b = sys.version_info[0] < 3 and (lambda x: x) or (lambda x: x.encode("latin1")) +from google.protobuf import descriptor as _descriptor +from google.protobuf import message as _message +from google.protobuf import reflection as _reflection +from google.protobuf import symbol_database as _symbol_database + +# @@protoc_insertion_point(imports) + +_sym_db = _symbol_database.Default() + + +from google.api import field_behavior_pb2 as google_dot_api_dot_field__behavior__pb2 +from google.protobuf import timestamp_pb2 as google_dot_protobuf_dot_timestamp__pb2 +from google.api import annotations_pb2 as google_dot_api_dot_annotations__pb2 + + +DESCRIPTOR = _descriptor.FileDescriptor( + name="google/cloud/spanner/admin/database_v1/proto/common.proto", + package="google.spanner.admin.database.v1", + syntax="proto3", + serialized_options=_b( + "\n$com.google.spanner.admin.database.v1B\013CommonProtoP\001ZHgoogle.golang.org/genproto/googleapis/spanner/admin/database/v1;database\252\002&Google.Cloud.Spanner.Admin.Database.V1\312\002&Google\\Cloud\\Spanner\\Admin\\Database\\V1" + ), + serialized_pb=_b( + '\n9google/cloud/spanner/admin/database_v1/proto/common.proto\x12 google.spanner.admin.database.v1\x1a\x1fgoogle/api/field_behavior.proto\x1a\x1fgoogle/protobuf/timestamp.proto\x1a\x1cgoogle/api/annotations.proto"\x8b\x01\n\x11OperationProgress\x12\x18\n\x10progress_percent\x18\x01 \x01(\x05\x12.\n\nstart_time\x18\x02 \x01(\x0b\x32\x1a.google.protobuf.Timestamp\x12,\n\x08\x65nd_time\x18\x03 \x01(\x0b\x32\x1a.google.protobuf.TimestampB\xd1\x01\n$com.google.spanner.admin.database.v1B\x0b\x43ommonProtoP\x01ZHgoogle.golang.org/genproto/googleapis/spanner/admin/database/v1;database\xaa\x02&Google.Cloud.Spanner.Admin.Database.V1\xca\x02&Google\\Cloud\\Spanner\\Admin\\Database\\V1b\x06proto3' + ), + dependencies=[ + google_dot_api_dot_field__behavior__pb2.DESCRIPTOR, + google_dot_protobuf_dot_timestamp__pb2.DESCRIPTOR, + google_dot_api_dot_annotations__pb2.DESCRIPTOR, + ], +) + + +_OPERATIONPROGRESS = _descriptor.Descriptor( + name="OperationProgress", + full_name="google.spanner.admin.database.v1.OperationProgress", + filename=None, + file=DESCRIPTOR, + containing_type=None, + fields=[ + _descriptor.FieldDescriptor( + name="progress_percent", + full_name="google.spanner.admin.database.v1.OperationProgress.progress_percent", + index=0, + number=1, + type=5, + cpp_type=1, + label=1, + has_default_value=False, + default_value=0, + message_type=None, + enum_type=None, + containing_type=None, + is_extension=False, + extension_scope=None, + serialized_options=None, + file=DESCRIPTOR, + ), + _descriptor.FieldDescriptor( + name="start_time", + full_name="google.spanner.admin.database.v1.OperationProgress.start_time", + index=1, + number=2, + type=11, + cpp_type=10, + label=1, + has_default_value=False, + default_value=None, + message_type=None, + enum_type=None, + containing_type=None, + is_extension=False, + extension_scope=None, + serialized_options=None, + file=DESCRIPTOR, + ), + _descriptor.FieldDescriptor( + name="end_time", + full_name="google.spanner.admin.database.v1.OperationProgress.end_time", + index=2, + number=3, + type=11, + cpp_type=10, + label=1, + has_default_value=False, + default_value=None, + message_type=None, + enum_type=None, + containing_type=None, + is_extension=False, + extension_scope=None, + serialized_options=None, + file=DESCRIPTOR, + ), + ], + extensions=[], + nested_types=[], + enum_types=[], + serialized_options=None, + is_extendable=False, + syntax="proto3", + extension_ranges=[], + oneofs=[], + serialized_start=192, + serialized_end=331, +) + +_OPERATIONPROGRESS.fields_by_name[ + "start_time" +].message_type = google_dot_protobuf_dot_timestamp__pb2._TIMESTAMP +_OPERATIONPROGRESS.fields_by_name[ + "end_time" +].message_type = google_dot_protobuf_dot_timestamp__pb2._TIMESTAMP +DESCRIPTOR.message_types_by_name["OperationProgress"] = _OPERATIONPROGRESS +_sym_db.RegisterFileDescriptor(DESCRIPTOR) + +OperationProgress = _reflection.GeneratedProtocolMessageType( + "OperationProgress", + (_message.Message,), + dict( + DESCRIPTOR=_OPERATIONPROGRESS, + __module__="google.cloud.spanner.admin.database_v1.proto.common_pb2", + __doc__="""Encapsulates progress related information for a Cloud + Spanner long running operation. + + + Attributes: + progress_percent: + Percent completion of the operation. Values are between 0 and + 100 inclusive. + start_time: + Time the request was received. + end_time: + If set, the time at which this operation failed or was + completed successfully. + """, + # @@protoc_insertion_point(class_scope:google.spanner.admin.database.v1.OperationProgress) + ), +) +_sym_db.RegisterMessage(OperationProgress) + + +DESCRIPTOR._options = None +# @@protoc_insertion_point(module_scope) diff --git a/google/cloud/spanner_admin_database_v1/proto/common_pb2_grpc.py b/google/cloud/spanner_admin_database_v1/proto/common_pb2_grpc.py new file mode 100644 index 0000000000..07cb78fe03 --- /dev/null +++ b/google/cloud/spanner_admin_database_v1/proto/common_pb2_grpc.py @@ -0,0 +1,2 @@ +# Generated by the gRPC Python protocol compiler plugin. DO NOT EDIT! +import grpc diff --git a/google/cloud/spanner_admin_database_v1/proto/spanner_database_admin.proto b/google/cloud/spanner_admin_database_v1/proto/spanner_database_admin.proto index ea5200b4cb..d48adc8aba 100644 --- a/google/cloud/spanner_admin_database_v1/proto/spanner_database_admin.proto +++ b/google/cloud/spanner_admin_database_v1/proto/spanner_database_admin.proto @@ -1,4 +1,4 @@ -// Copyright 2019 Google LLC. +// Copyright 2020 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -11,7 +11,6 @@ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. -// syntax = "proto3"; @@ -26,6 +25,8 @@ import "google/iam/v1/policy.proto"; import "google/longrunning/operations.proto"; import "google/protobuf/empty.proto"; import "google/protobuf/timestamp.proto"; +import "google/spanner/admin/database/v1/backup.proto"; +import "google/spanner/admin/database/v1/common.proto"; option csharp_namespace = "Google.Cloud.Spanner.Admin.Database.V1"; option go_package = "google.golang.org/genproto/googleapis/spanner/admin/database/v1;database"; @@ -33,10 +34,6 @@ option java_multiple_files = true; option java_outer_classname = "SpannerDatabaseAdminProto"; option java_package = "com.google.spanner.admin.database.v1"; option php_namespace = "Google\\Cloud\\Spanner\\Admin\\Database\\V1"; - -// The Instance resource is defined in `google.spanner.admin.instance.v1`. -// Because this is a separate, independent API (technically), we redefine -// the resource name pattern here. option (google.api.resource_definition) = { type: "spanner.googleapis.com/Instance" pattern: "projects/{project}/instances/{instance}" @@ -46,7 +43,8 @@ option (google.api.resource_definition) = { // // 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. +// databases. It can be also used to create, delete and list backups for a +// database and to restore from an existing backup. service DatabaseAdmin { option (google.api.default_host) = "spanner.googleapis.com"; option (google.api.oauth_scopes) = @@ -66,11 +64,10 @@ service DatabaseAdmin { // 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 + // [CreateDatabaseMetadata][google.spanner.admin.database.v1.CreateDatabaseMetadata]. The + // [response][google.longrunning.Operation.response] field type is // [Database][google.spanner.admin.database.v1.Database], if successful. - rpc CreateDatabase(CreateDatabaseRequest) - returns (google.longrunning.Operation) { + rpc CreateDatabase(CreateDatabaseRequest) returns (google.longrunning.Operation) { option (google.api.http) = { post: "/v1/{parent=projects/*/instances/*}/databases" body: "*" @@ -96,10 +93,8 @@ service DatabaseAdmin { // the format `/operations/` and can be used to // track execution of the schema change(s). The // [metadata][google.longrunning.Operation.metadata] field type is - // [UpdateDatabaseDdlMetadata][google.spanner.admin.database.v1.UpdateDatabaseDdlMetadata]. - // The operation has no response. - rpc UpdateDatabaseDdl(UpdateDatabaseDdlRequest) - returns (google.longrunning.Operation) { + // [UpdateDatabaseDdlMetadata][google.spanner.admin.database.v1.UpdateDatabaseDdlMetadata]. The operation has no response. + rpc UpdateDatabaseDdl(UpdateDatabaseDdlRequest) returns (google.longrunning.Operation) { option (google.api.http) = { patch: "/v1/{database=projects/*/instances/*/databases/*}/ddl" body: "*" @@ -112,6 +107,8 @@ service DatabaseAdmin { } // Drops (aka deletes) a Cloud Spanner database. + // Completed backups for the database will be retained according to their + // `expire_time`. rpc DropDatabase(DropDatabaseRequest) returns (google.protobuf.Empty) { option (google.api.http) = { delete: "/v1/{database=projects/*/instances/*/databases/*}" @@ -129,13 +126,14 @@ service DatabaseAdmin { option (google.api.method_signature) = "database"; } - // Sets the access control policy on a database resource. + // Sets the access control policy on a database or backup resource. // Replaces any existing policy. // // Authorization requires `spanner.databases.setIamPolicy` // permission on [resource][google.iam.v1.SetIamPolicyRequest.resource]. - rpc SetIamPolicy(google.iam.v1.SetIamPolicyRequest) - returns (google.iam.v1.Policy) { + // For backups, authorization requires `spanner.backups.setIamPolicy` + // permission on [resource][google.iam.v1.SetIamPolicyRequest.resource]. + rpc SetIamPolicy(google.iam.v1.SetIamPolicyRequest) returns (google.iam.v1.Policy) { option (google.api.http) = { post: "/v1/{resource=projects/*/instances/*/databases/*}:setIamPolicy" body: "*" @@ -147,14 +145,15 @@ service DatabaseAdmin { option (google.api.method_signature) = "resource,policy"; } - // Gets the access control policy for a database resource. - // Returns an empty policy if a database exists but does - // not have a policy set. + // Gets the access control policy for a database or backup resource. + // Returns an empty policy if a database or backup exists but does not have a + // policy set. // // Authorization requires `spanner.databases.getIamPolicy` permission on // [resource][google.iam.v1.GetIamPolicyRequest.resource]. - rpc GetIamPolicy(google.iam.v1.GetIamPolicyRequest) - returns (google.iam.v1.Policy) { + // For backups, authorization requires `spanner.backups.getIamPolicy` + // permission on [resource][google.iam.v1.GetIamPolicyRequest.resource]. + rpc GetIamPolicy(google.iam.v1.GetIamPolicyRequest) returns (google.iam.v1.Policy) { option (google.api.http) = { post: "/v1/{resource=projects/*/instances/*/databases/*}:getIamPolicy" body: "*" @@ -166,14 +165,17 @@ service DatabaseAdmin { option (google.api.method_signature) = "resource"; } - // Returns permissions that the caller has on the specified database resource. + // Returns permissions that the caller has on the specified database or backup + // resource. // // Attempting this RPC on a non-existent Cloud Spanner database will // result in a NOT_FOUND error if the user has // `spanner.databases.list` permission on the containing Cloud // Spanner instance. Otherwise returns an empty set of permissions. - rpc TestIamPermissions(google.iam.v1.TestIamPermissionsRequest) - returns (google.iam.v1.TestIamPermissionsResponse) { + // Calling this method on a backup that does not exist will + // result in a NOT_FOUND error if the user has + // `spanner.backups.list` permission on the containing instance. + rpc TestIamPermissions(google.iam.v1.TestIamPermissionsRequest) returns (google.iam.v1.TestIamPermissionsResponse) { option (google.api.http) = { post: "/v1/{resource=projects/*/instances/*/databases/*}:testIamPermissions" body: "*" @@ -184,6 +186,139 @@ service DatabaseAdmin { }; option (google.api.method_signature) = "resource,permissions"; } + + // Starts creating a new Cloud Spanner Backup. + // The returned backup [long-running operation][google.longrunning.Operation] + // will have a name of the format + // `projects//instances//backups//operations/` + // and can be used to track creation of the backup. The + // [metadata][google.longrunning.Operation.metadata] field type is + // [CreateBackupMetadata][google.spanner.admin.database.v1.CreateBackupMetadata]. The + // [response][google.longrunning.Operation.response] field type is + // [Backup][google.spanner.admin.database.v1.Backup], if successful. Cancelling the returned operation will stop the + // creation and delete the backup. + // There can be only one pending backup creation per database. Backup creation + // of different databases can run concurrently. + rpc CreateBackup(CreateBackupRequest) returns (google.longrunning.Operation) { + option (google.api.http) = { + post: "/v1/{parent=projects/*/instances/*}/backups" + body: "backup" + }; + option (google.api.method_signature) = "parent,backup,backup_id"; + option (google.longrunning.operation_info) = { + response_type: "Backup" + metadata_type: "google.spanner.admin.database.v1.CreateBackupMetadata" + }; + } + + // Gets metadata on a pending or completed [Backup][google.spanner.admin.database.v1.Backup]. + rpc GetBackup(GetBackupRequest) returns (Backup) { + option (google.api.http) = { + get: "/v1/{name=projects/*/instances/*/backups/*}" + }; + option (google.api.method_signature) = "name"; + } + + // Updates a pending or completed [Backup][google.spanner.admin.database.v1.Backup]. + rpc UpdateBackup(UpdateBackupRequest) returns (Backup) { + option (google.api.http) = { + patch: "/v1/{backup.name=projects/*/instances/*/backups/*}" + body: "backup" + }; + option (google.api.method_signature) = "backup,update_mask"; + } + + // Deletes a pending or completed [Backup][google.spanner.admin.database.v1.Backup]. + rpc DeleteBackup(DeleteBackupRequest) returns (google.protobuf.Empty) { + option (google.api.http) = { + delete: "/v1/{name=projects/*/instances/*/backups/*}" + }; + option (google.api.method_signature) = "name"; + } + + // Lists completed and pending backups. + // Backups returned are ordered by `create_time` in descending order, + // starting from the most recent `create_time`. + rpc ListBackups(ListBackupsRequest) returns (ListBackupsResponse) { + option (google.api.http) = { + get: "/v1/{parent=projects/*/instances/*}/backups" + }; + option (google.api.method_signature) = "parent"; + } + + // Create a new database by restoring from a completed backup. The new + // database must be in the same project and in an instance with the same + // instance configuration as the instance containing + // the backup. The returned database [long-running + // operation][google.longrunning.Operation] has a name of the format + // `projects//instances//databases//operations/`, + // and can be used to track the progress of the operation, and to cancel it. + // The [metadata][google.longrunning.Operation.metadata] field type is + // [RestoreDatabaseMetadata][google.spanner.admin.database.v1.RestoreDatabaseMetadata]. + // The [response][google.longrunning.Operation.response] type + // is [Database][google.spanner.admin.database.v1.Database], if + // successful. Cancelling the returned operation will stop the restore and + // delete the database. + // There can be only one database being restored into an instance at a time. + // Once the restore operation completes, a new restore operation can be + // initiated, without waiting for the optimize operation associated with the + // first restore to complete. + rpc RestoreDatabase(RestoreDatabaseRequest) returns (google.longrunning.Operation) { + option (google.api.http) = { + post: "/v1/{parent=projects/*/instances/*}/databases:restore" + body: "*" + }; + option (google.api.method_signature) = "parent,database_id,backup"; + option (google.longrunning.operation_info) = { + response_type: "google.spanner.admin.database.v1.Database" + metadata_type: "google.spanner.admin.database.v1.RestoreDatabaseMetadata" + }; + } + + // Lists database [longrunning-operations][google.longrunning.Operation]. + // A database operation has a name of the form + // `projects//instances//databases//operations/`. + // The long-running operation + // [metadata][google.longrunning.Operation.metadata] field type + // `metadata.type_url` describes the type of the metadata. Operations returned + // include those that have completed/failed/canceled within the last 7 days, + // and pending operations. + rpc ListDatabaseOperations(ListDatabaseOperationsRequest) returns (ListDatabaseOperationsResponse) { + option (google.api.http) = { + get: "/v1/{parent=projects/*/instances/*}/databaseOperations" + }; + option (google.api.method_signature) = "parent"; + } + + // Lists the backup [long-running operations][google.longrunning.Operation] in + // the given instance. A backup operation has a name of the form + // `projects//instances//backups//operations/`. + // The long-running operation + // [metadata][google.longrunning.Operation.metadata] field type + // `metadata.type_url` describes the type of the metadata. Operations returned + // include those that have completed/failed/canceled within the last 7 days, + // and pending operations. Operations returned are ordered by + // `operation.metadata.value.progress.start_time` in descending order starting + // from the most recently started operation. + rpc ListBackupOperations(ListBackupOperationsRequest) returns (ListBackupOperationsResponse) { + option (google.api.http) = { + get: "/v1/{parent=projects/*/instances/*}/backupOperations" + }; + option (google.api.method_signature) = "parent"; + } +} + +// Information about the database restore. +message RestoreInfo { + // The type of the restore source. + RestoreSourceType source_type = 1; + + // Information about the source used to restore the database. + oneof source_info { + // Information about the backup used to restore the database. The backup + // may no longer exist. + BackupInfo backup_info = 2; + } } // A Cloud Spanner database. @@ -204,6 +339,16 @@ message Database { // The database is fully created and ready for use. READY = 2; + + // The database is fully created and ready for use, but is still + // being optimized for performance and cannot handle full load. + // + // In this state, the database still references the backup + // it was restore from, preventing the backup + // from being deleted. When optimizations are complete, the full performance + // of the database will be restored, and the database will transition to + // `READY` state. + READY_OPTIMIZING = 3; } // Required. The name of the database. Values are of the form @@ -211,14 +356,20 @@ message Database { // where `` is as specified in the `CREATE DATABASE` // statement. This name can be passed to other API methods to // identify the database. - string name = 1; + string name = 1 [(google.api.field_behavior) = REQUIRED]; // Output only. The current database state. - State state = 2; + State state = 2 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. If exists, the time at which the database creation started. + google.protobuf.Timestamp create_time = 3 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. Applicable only for restored databases. Contains information + // about the restore source. + RestoreInfo restore_info = 4 [(google.api.field_behavior) = OUTPUT_ONLY]; } -// The request for -// [ListDatabases][google.spanner.admin.database.v1.DatabaseAdmin.ListDatabases]. +// The request for [ListDatabases][google.spanner.admin.database.v1.DatabaseAdmin.ListDatabases]. message ListDatabasesRequest { // Required. The instance whose databases should be listed. // Values are of the form `projects//instances/`. @@ -234,26 +385,23 @@ message ListDatabasesRequest { int32 page_size = 3; // If non-empty, `page_token` should contain a - // [next_page_token][google.spanner.admin.database.v1.ListDatabasesResponse.next_page_token] - // from a previous - // [ListDatabasesResponse][google.spanner.admin.database.v1.ListDatabasesResponse]. + // [next_page_token][google.spanner.admin.database.v1.ListDatabasesResponse.next_page_token] from a + // previous [ListDatabasesResponse][google.spanner.admin.database.v1.ListDatabasesResponse]. string page_token = 4; } -// The response for -// [ListDatabases][google.spanner.admin.database.v1.DatabaseAdmin.ListDatabases]. +// The response for [ListDatabases][google.spanner.admin.database.v1.DatabaseAdmin.ListDatabases]. message ListDatabasesResponse { // Databases that matched the request. repeated Database databases = 1; // `next_page_token` can be sent in a subsequent - // [ListDatabases][google.spanner.admin.database.v1.DatabaseAdmin.ListDatabases] - // call to fetch more of the matching databases. + // [ListDatabases][google.spanner.admin.database.v1.DatabaseAdmin.ListDatabases] call to fetch more + // of the matching databases. string next_page_token = 2; } -// The request for -// [CreateDatabase][google.spanner.admin.database.v1.DatabaseAdmin.CreateDatabase]. +// The request for [CreateDatabase][google.spanner.admin.database.v1.DatabaseAdmin.CreateDatabase]. message CreateDatabaseRequest { // Required. The name of the instance that will serve the new database. // Values are of the form `projects//instances/`. @@ -271,11 +419,11 @@ message CreateDatabaseRequest { // database ID must be enclosed in backticks (`` ` ``). string create_statement = 2 [(google.api.field_behavior) = REQUIRED]; - // An optional list of DDL statements to run inside the newly created + // Optional. A list of DDL statements to run inside the newly created // database. Statements can create tables, indexes, etc. These // statements execute atomically with the creation of the database: // if there is an error in any statement, the database is not created. - repeated string extra_statements = 3; + repeated string extra_statements = 3 [(google.api.field_behavior) = OPTIONAL]; } // Metadata type for the operation returned by @@ -283,12 +431,11 @@ message CreateDatabaseRequest { message CreateDatabaseMetadata { // The database being created. string database = 1 [(google.api.resource_reference) = { - type: "spanner.googleapis.com/Database" - }]; + type: "spanner.googleapis.com/Database" + }]; } -// The request for -// [GetDatabase][google.spanner.admin.database.v1.DatabaseAdmin.GetDatabase]. +// The request for [GetDatabase][google.spanner.admin.database.v1.DatabaseAdmin.GetDatabase]. message GetDatabaseRequest { // Required. The name of the requested database. Values are of the form // `projects//instances//databases/`. @@ -314,8 +461,8 @@ message GetDatabaseRequest { // Each batch of statements is assigned a name which can be used with // the [Operations][google.longrunning.Operations] API to monitor // progress. See the -// [operation_id][google.spanner.admin.database.v1.UpdateDatabaseDdlRequest.operation_id] -// field for more details. +// [operation_id][google.spanner.admin.database.v1.UpdateDatabaseDdlRequest.operation_id] field for more +// details. message UpdateDatabaseDdlRequest { // Required. The database to update. string database = 1 [ @@ -335,20 +482,18 @@ message UpdateDatabaseDdlRequest { // // Specifying an explicit operation ID simplifies determining // whether the statements were executed in the event that the - // [UpdateDatabaseDdl][google.spanner.admin.database.v1.DatabaseAdmin.UpdateDatabaseDdl] - // call is replayed, or the return value is otherwise lost: the - // [database][google.spanner.admin.database.v1.UpdateDatabaseDdlRequest.database] - // and `operation_id` fields can be combined to form the + // [UpdateDatabaseDdl][google.spanner.admin.database.v1.DatabaseAdmin.UpdateDatabaseDdl] call is replayed, + // or the return value is otherwise lost: the [database][google.spanner.admin.database.v1.UpdateDatabaseDdlRequest.database] and + // `operation_id` fields can be combined to form the // [name][google.longrunning.Operation.name] of the resulting - // [longrunning.Operation][google.longrunning.Operation]: - // `/operations/`. + // [longrunning.Operation][google.longrunning.Operation]: `/operations/`. // // `operation_id` should be unique within the database, and must be // a valid identifier: `[a-z][a-z0-9_]*`. Note that // automatically-generated operation IDs always begin with an // underscore. If the named operation already exists, - // [UpdateDatabaseDdl][google.spanner.admin.database.v1.DatabaseAdmin.UpdateDatabaseDdl] - // returns `ALREADY_EXISTS`. + // [UpdateDatabaseDdl][google.spanner.admin.database.v1.DatabaseAdmin.UpdateDatabaseDdl] returns + // `ALREADY_EXISTS`. string operation_id = 3; } @@ -357,8 +502,8 @@ message UpdateDatabaseDdlRequest { message UpdateDatabaseDdlMetadata { // The database being modified. string database = 1 [(google.api.resource_reference) = { - type: "spanner.googleapis.com/Database" - }]; + type: "spanner.googleapis.com/Database" + }]; // For an update this list contains all the statements. For an // individual statement, this list contains only that statement. @@ -370,8 +515,7 @@ message UpdateDatabaseDdlMetadata { repeated google.protobuf.Timestamp commit_timestamps = 3; } -// The request for -// [DropDatabase][google.spanner.admin.database.v1.DatabaseAdmin.DropDatabase]. +// The request for [DropDatabase][google.spanner.admin.database.v1.DatabaseAdmin.DropDatabase]. message DropDatabaseRequest { // Required. The database to be dropped. string database = 1 [ @@ -382,8 +526,7 @@ message DropDatabaseRequest { ]; } -// The request for -// [GetDatabaseDdl][google.spanner.admin.database.v1.DatabaseAdmin.GetDatabaseDdl]. +// The request for [GetDatabaseDdl][google.spanner.admin.database.v1.DatabaseAdmin.GetDatabaseDdl]. message GetDatabaseDdlRequest { // Required. The database whose schema we wish to get. string database = 1 [ @@ -394,10 +537,190 @@ message GetDatabaseDdlRequest { ]; } -// The response for -// [GetDatabaseDdl][google.spanner.admin.database.v1.DatabaseAdmin.GetDatabaseDdl]. +// The response for [GetDatabaseDdl][google.spanner.admin.database.v1.DatabaseAdmin.GetDatabaseDdl]. message GetDatabaseDdlResponse { // A list of formatted DDL statements defining the schema of the database // specified in the request. repeated string statements = 1; } + +// The request for +// [ListDatabaseOperations][google.spanner.admin.database.v1.DatabaseAdmin.ListDatabaseOperations]. +message ListDatabaseOperationsRequest { + // Required. The instance of the database operations. + // Values are of the form `projects//instances/`. + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "spanner.googleapis.com/Instance" + } + ]; + + // An expression that filters the list of returned operations. + // + // A filter expression consists of a field name, a + // comparison operator, and a value for filtering. + // The value must be a string, a number, or a boolean. The comparison operator + // must be one of: `<`, `>`, `<=`, `>=`, `!=`, `=`, or `:`. + // Colon `:` is the contains operator. Filter rules are not case sensitive. + // + // The following fields in the [Operation][google.longrunning.Operation] + // are eligible for filtering: + // + // * `name` - The name of the long-running operation + // * `done` - False if the operation is in progress, else true. + // * `metadata.@type` - the type of metadata. For example, the type string + // for [RestoreDatabaseMetadata][google.spanner.admin.database.v1.RestoreDatabaseMetadata] is + // `type.googleapis.com/google.spanner.admin.database.v1.RestoreDatabaseMetadata`. + // * `metadata.` - any field in metadata.value. + // * `error` - Error associated with the long-running operation. + // * `response.@type` - the type of response. + // * `response.` - any field in response.value. + // + // You can combine multiple expressions by enclosing each expression in + // parentheses. By default, expressions are combined with AND logic. However, + // you can specify AND, OR, and NOT logic explicitly. + // + // Here are a few examples: + // + // * `done:true` - The operation is complete. + // * `(metadata.@type=type.googleapis.com/google.spanner.admin.database.v1.RestoreDatabaseMetadata) AND`
+ // `(metadata.source_type:BACKUP) AND`
+ // `(metadata.backup_info.backup:backup_howl) AND`
+ // `(metadata.name:restored_howl) AND`
+ // `(metadata.progress.start_time < \"2018-03-28T14:50:00Z\") AND`
+ // `(error:*)` - Return operations where: + // * The operation's metadata type is [RestoreDatabaseMetadata][google.spanner.admin.database.v1.RestoreDatabaseMetadata]. + // * The database is restored from a backup. + // * The backup name contains "backup_howl". + // * The restored database's name contains "restored_howl". + // * The operation started before 2018-03-28T14:50:00Z. + // * The operation resulted in an error. + string filter = 2; + + // Number of operations to be returned in the response. If 0 or + // less, defaults to the server's maximum allowed page size. + int32 page_size = 3; + + // If non-empty, `page_token` should contain a + // [next_page_token][google.spanner.admin.database.v1.ListDatabaseOperationsResponse.next_page_token] + // from a previous [ListDatabaseOperationsResponse][google.spanner.admin.database.v1.ListDatabaseOperationsResponse] to the + // same `parent` and with the same `filter`. + string page_token = 4; +} + +// The response for +// [ListDatabaseOperations][google.spanner.admin.database.v1.DatabaseAdmin.ListDatabaseOperations]. +message ListDatabaseOperationsResponse { + // The list of matching database [long-running + // operations][google.longrunning.Operation]. Each operation's name will be + // prefixed by the database's name. The operation's + // [metadata][google.longrunning.Operation.metadata] field type + // `metadata.type_url` describes the type of the metadata. + repeated google.longrunning.Operation operations = 1; + + // `next_page_token` can be sent in a subsequent + // [ListDatabaseOperations][google.spanner.admin.database.v1.DatabaseAdmin.ListDatabaseOperations] + // call to fetch more of the matching metadata. + string next_page_token = 2; +} + +// The request for +// [RestoreDatabase][google.spanner.admin.database.v1.DatabaseAdmin.RestoreDatabase]. +message RestoreDatabaseRequest { + // Required. The name of the instance in which to create the + // restored database. This instance must be in the same project and + // have the same instance configuration as the instance containing + // the source backup. Values are of the form + // `projects//instances/`. + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "spanner.googleapis.com/Instance" + } + ]; + + // Required. The id of the database to create and restore to. This + // database must not already exist. The `database_id` appended to + // `parent` forms the full database name of the form + // `projects//instances//databases/`. + string database_id = 2 [(google.api.field_behavior) = REQUIRED]; + + // Required. The source from which to restore. + oneof source { + // Name of the backup from which to restore. Values are of the form + // `projects//instances//backups/`. + string backup = 3 [(google.api.resource_reference) = { + type: "spanner.googleapis.com/Backup" + }]; + } +} + +// Metadata type for the long-running operation returned by +// [RestoreDatabase][google.spanner.admin.database.v1.DatabaseAdmin.RestoreDatabase]. +message RestoreDatabaseMetadata { + // Name of the database being created and restored to. + string name = 1; + + // The type of the restore source. + RestoreSourceType source_type = 2; + + // Information about the source used to restore the database, as specified by + // `source` in [RestoreDatabaseRequest][google.spanner.admin.database.v1.RestoreDatabaseRequest]. + oneof source_info { + // Information about the backup used to restore the database. + BackupInfo backup_info = 3; + } + + // The progress of the + // [RestoreDatabase][google.spanner.admin.database.v1.DatabaseAdmin.RestoreDatabase] + // operation. + OperationProgress progress = 4; + + // The time at which cancellation of this operation was received. + // [Operations.CancelOperation][google.longrunning.Operations.CancelOperation] + // starts asynchronous cancellation on a long-running operation. The server + // makes a best effort to cancel the operation, but success is not guaranteed. + // Clients can use + // [Operations.GetOperation][google.longrunning.Operations.GetOperation] or + // other methods to check whether the cancellation succeeded or whether the + // operation completed despite cancellation. On successful cancellation, + // the operation is not deleted; instead, it becomes an operation with + // an [Operation.error][google.longrunning.Operation.error] value with a + // [google.rpc.Status.code][google.rpc.Status.code] of 1, corresponding to `Code.CANCELLED`. + google.protobuf.Timestamp cancel_time = 5; + + // If exists, the name of the long-running operation that will be used to + // track the post-restore optimization process to optimize the performance of + // the restored database, and remove the dependency on the restore source. + // The name is of the form + // `projects//instances//databases//operations/` + // where the is the name of database being created and restored to. + // The metadata type of the long-running operation is + // [OptimizeRestoredDatabaseMetadata][google.spanner.admin.database.v1.OptimizeRestoredDatabaseMetadata]. This long-running operation will be + // automatically created by the system after the RestoreDatabase long-running + // operation completes successfully. This operation will not be created if the + // restore was not successful. + string optimize_database_operation_name = 6; +} + +// Metadata type for the long-running operation used to track the progress +// of optimizations performed on a newly restored database. This long-running +// operation is automatically created by the system after the successful +// completion of a database restore, and cannot be cancelled. +message OptimizeRestoredDatabaseMetadata { + // Name of the restored database being optimized. + string name = 1; + + // The progress of the post-restore optimizations. + OperationProgress progress = 2; +} + +// Indicates the type of the restore source. +enum RestoreSourceType { + // No restore associated. + TYPE_UNSPECIFIED = 0; + + // A backup was used as the source of the restore. + BACKUP = 1; +} diff --git a/google/cloud/spanner_admin_database_v1/proto/spanner_database_admin_pb2.py b/google/cloud/spanner_admin_database_v1/proto/spanner_database_admin_pb2.py index 35fd22717e..125ab3f86b 100644 --- a/google/cloud/spanner_admin_database_v1/proto/spanner_database_admin_pb2.py +++ b/google/cloud/spanner_admin_database_v1/proto/spanner_database_admin_pb2.py @@ -5,6 +5,7 @@ import sys _b = sys.version_info[0] < 3 and (lambda x: x) or (lambda x: x.encode("latin1")) +from google.protobuf.internal import enum_type_wrapper from google.protobuf import descriptor as _descriptor from google.protobuf import message as _message from google.protobuf import reflection as _reflection @@ -26,6 +27,12 @@ ) from google.protobuf import empty_pb2 as google_dot_protobuf_dot_empty__pb2 from google.protobuf import timestamp_pb2 as google_dot_protobuf_dot_timestamp__pb2 +from google.cloud.spanner_admin_database_v1.proto import ( + backup_pb2 as google_dot_cloud_dot_spanner_dot_admin_dot_database__v1_dot_proto_dot_backup__pb2, +) +from google.cloud.spanner_admin_database_v1.proto import ( + common_pb2 as google_dot_cloud_dot_spanner_dot_admin_dot_database__v1_dot_proto_dot_common__pb2, +) DESCRIPTOR = _descriptor.FileDescriptor( @@ -36,7 +43,7 @@ "\n$com.google.spanner.admin.database.v1B\031SpannerDatabaseAdminProtoP\001ZHgoogle.golang.org/genproto/googleapis/spanner/admin/database/v1;database\252\002&Google.Cloud.Spanner.Admin.Database.V1\312\002&Google\\Cloud\\Spanner\\Admin\\Database\\V1\352AJ\n\037spanner.googleapis.com/Instance\022'projects/{project}/instances/{instance}" ), serialized_pb=_b( - '\nIgoogle/cloud/spanner/admin/database_v1/proto/spanner_database_admin.proto\x12 google.spanner.admin.database.v1\x1a\x1cgoogle/api/annotations.proto\x1a\x17google/api/client.proto\x1a\x1fgoogle/api/field_behavior.proto\x1a\x19google/api/resource.proto\x1a\x1egoogle/iam/v1/iam_policy.proto\x1a\x1agoogle/iam/v1/policy.proto\x1a#google/longrunning/operations.proto\x1a\x1bgoogle/protobuf/empty.proto\x1a\x1fgoogle/protobuf/timestamp.proto"\xf6\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:b\xea\x41_\n\x1fspanner.googleapis.com/Database\x12\x82\xd3\xe4\x93\x02/\x12-/v1/{parent=projects/*/instances/*}/databases\xda\x41\x06parent\x12\xa4\x02\n\x0e\x43reateDatabase\x12\x37.google.spanner.admin.database.v1.CreateDatabaseRequest\x1a\x1d.google.longrunning.Operation"\xb9\x01\x82\xd3\xe4\x93\x02\x32"-/v1/{parent=projects/*/instances/*}/databases:\x01*\xda\x41\x17parent,create_statement\xca\x41\x64\n)google.spanner.admin.database.v1.Database\x12\x37google.spanner.admin.database.v1.CreateDatabaseMetadata\x12\xad\x01\n\x0bGetDatabase\x12\x34.google.spanner.admin.database.v1.GetDatabaseRequest\x1a*.google.spanner.admin.database.v1.Database"<\x82\xd3\xe4\x93\x02/\x12-/v1/{name=projects/*/instances/*/databases/*}\xda\x41\x04name\x12\x9d\x02\n\x11UpdateDatabaseDdl\x12:.google.spanner.admin.database.v1.UpdateDatabaseDdlRequest\x1a\x1d.google.longrunning.Operation"\xac\x01\x82\xd3\xe4\x93\x02:25/v1/{database=projects/*/instances/*/databases/*}/ddl:\x01*\xda\x41\x13\x64\x61tabase,statements\xca\x41S\n\x15google.protobuf.Empty\x12:google.spanner.admin.database.v1.UpdateDatabaseDdlMetadata\x12\xa3\x01\n\x0c\x44ropDatabase\x12\x35.google.spanner.admin.database.v1.DropDatabaseRequest\x1a\x16.google.protobuf.Empty"D\x82\xd3\xe4\x93\x02\x33*1/v1/{database=projects/*/instances/*/databases/*}\xda\x41\x08\x64\x61tabase\x12\xcd\x01\n\x0eGetDatabaseDdl\x12\x37.google.spanner.admin.database.v1.GetDatabaseDdlRequest\x1a\x38.google.spanner.admin.database.v1.GetDatabaseDdlResponse"H\x82\xd3\xe4\x93\x02\x37\x12\x35/v1/{database=projects/*/instances/*/databases/*}/ddl\xda\x41\x08\x64\x61tabase\x12\xeb\x01\n\x0cSetIamPolicy\x12".google.iam.v1.SetIamPolicyRequest\x1a\x15.google.iam.v1.Policy"\x9f\x01\x82\xd3\xe4\x93\x02\x86\x01">/v1/{resource=projects/*/instances/*/databases/*}:setIamPolicy:\x01*ZA"/v1/{resource=projects/*/instances/*/databases/*}:getIamPolicy:\x01*ZA"\x82\xd3\xe4\x93\x02/\x12-/v1/{parent=projects/*/instances/*}/databases\xda\x41\x06parent\x12\xa4\x02\n\x0e\x43reateDatabase\x12\x37.google.spanner.admin.database.v1.CreateDatabaseRequest\x1a\x1d.google.longrunning.Operation"\xb9\x01\x82\xd3\xe4\x93\x02\x32"-/v1/{parent=projects/*/instances/*}/databases:\x01*\xda\x41\x17parent,create_statement\xca\x41\x64\n)google.spanner.admin.database.v1.Database\x12\x37google.spanner.admin.database.v1.CreateDatabaseMetadata\x12\xad\x01\n\x0bGetDatabase\x12\x34.google.spanner.admin.database.v1.GetDatabaseRequest\x1a*.google.spanner.admin.database.v1.Database"<\x82\xd3\xe4\x93\x02/\x12-/v1/{name=projects/*/instances/*/databases/*}\xda\x41\x04name\x12\x9d\x02\n\x11UpdateDatabaseDdl\x12:.google.spanner.admin.database.v1.UpdateDatabaseDdlRequest\x1a\x1d.google.longrunning.Operation"\xac\x01\x82\xd3\xe4\x93\x02:25/v1/{database=projects/*/instances/*/databases/*}/ddl:\x01*\xda\x41\x13\x64\x61tabase,statements\xca\x41S\n\x15google.protobuf.Empty\x12:google.spanner.admin.database.v1.UpdateDatabaseDdlMetadata\x12\xa3\x01\n\x0c\x44ropDatabase\x12\x35.google.spanner.admin.database.v1.DropDatabaseRequest\x1a\x16.google.protobuf.Empty"D\x82\xd3\xe4\x93\x02\x33*1/v1/{database=projects/*/instances/*/databases/*}\xda\x41\x08\x64\x61tabase\x12\xcd\x01\n\x0eGetDatabaseDdl\x12\x37.google.spanner.admin.database.v1.GetDatabaseDdlRequest\x1a\x38.google.spanner.admin.database.v1.GetDatabaseDdlResponse"H\x82\xd3\xe4\x93\x02\x37\x12\x35/v1/{database=projects/*/instances/*/databases/*}/ddl\xda\x41\x08\x64\x61tabase\x12\xeb\x01\n\x0cSetIamPolicy\x12".google.iam.v1.SetIamPolicyRequest\x1a\x15.google.iam.v1.Policy"\x9f\x01\x82\xd3\xe4\x93\x02\x86\x01">/v1/{resource=projects/*/instances/*/databases/*}:setIamPolicy:\x01*ZA"/v1/{resource=projects/*/instances/*/databases/*}:getIamPolicy:\x01*ZA".google.spanner.admin.database.v1.ListBackupOperationsResponse"E\x82\xd3\xe4\x93\x02\x36\x12\x34/v1/{parent=projects/*/instances/*}/backupOperations\xda\x41\x06parent\x1ax\xca\x41\x16spanner.googleapis.com\xd2\x41\\https://www.googleapis.com/auth/cloud-platform,https://www.googleapis.com/auth/spanner.adminB\xac\x02\n$com.google.spanner.admin.database.v1B\x19SpannerDatabaseAdminProtoP\x01ZHgoogle.golang.org/genproto/googleapis/spanner/admin/database/v1;database\xaa\x02&Google.Cloud.Spanner.Admin.Database.V1\xca\x02&Google\\Cloud\\Spanner\\Admin\\Database\\V1\xea\x41J\n\x1fspanner.googleapis.com/Instance\x12\'projects/{project}/instances/{instance}b\x06proto3' ), dependencies=[ google_dot_api_dot_annotations__pb2.DESCRIPTOR, @@ -48,8 +55,38 @@ google_dot_longrunning_dot_operations__pb2.DESCRIPTOR, google_dot_protobuf_dot_empty__pb2.DESCRIPTOR, google_dot_protobuf_dot_timestamp__pb2.DESCRIPTOR, + google_dot_cloud_dot_spanner_dot_admin_dot_database__v1_dot_proto_dot_backup__pb2.DESCRIPTOR, + google_dot_cloud_dot_spanner_dot_admin_dot_database__v1_dot_proto_dot_common__pb2.DESCRIPTOR, + ], +) + +_RESTORESOURCETYPE = _descriptor.EnumDescriptor( + name="RestoreSourceType", + full_name="google.spanner.admin.database.v1.RestoreSourceType", + filename=None, + file=DESCRIPTOR, + values=[ + _descriptor.EnumValueDescriptor( + name="TYPE_UNSPECIFIED", + index=0, + number=0, + serialized_options=None, + type=None, + ), + _descriptor.EnumValueDescriptor( + name="BACKUP", index=1, number=1, serialized_options=None, type=None + ), ], + containing_type=None, + serialized_options=None, + serialized_start=3044, + serialized_end=3097, ) +_sym_db.RegisterEnumDescriptor(_RESTORESOURCETYPE) + +RestoreSourceType = enum_type_wrapper.EnumTypeWrapper(_RESTORESOURCETYPE) +TYPE_UNSPECIFIED = 0 +BACKUP = 1 _DATABASE_STATE = _descriptor.EnumDescriptor( @@ -71,15 +108,87 @@ _descriptor.EnumValueDescriptor( name="READY", index=2, number=2, serialized_options=None, type=None ), + _descriptor.EnumValueDescriptor( + name="READY_OPTIMIZING", + index=3, + number=3, + serialized_options=None, + type=None, + ), ], containing_type=None, serialized_options=None, - serialized_start=477, - serialized_end=532, + serialized_start=907, + serialized_end=984, ) _sym_db.RegisterEnumDescriptor(_DATABASE_STATE) +_RESTOREINFO = _descriptor.Descriptor( + name="RestoreInfo", + full_name="google.spanner.admin.database.v1.RestoreInfo", + filename=None, + file=DESCRIPTOR, + containing_type=None, + fields=[ + _descriptor.FieldDescriptor( + name="source_type", + full_name="google.spanner.admin.database.v1.RestoreInfo.source_type", + index=0, + number=1, + type=14, + cpp_type=8, + label=1, + has_default_value=False, + default_value=0, + message_type=None, + enum_type=None, + containing_type=None, + is_extension=False, + extension_scope=None, + serialized_options=None, + file=DESCRIPTOR, + ), + _descriptor.FieldDescriptor( + name="backup_info", + full_name="google.spanner.admin.database.v1.RestoreInfo.backup_info", + index=1, + number=2, + type=11, + cpp_type=10, + label=1, + has_default_value=False, + default_value=None, + message_type=None, + enum_type=None, + containing_type=None, + is_extension=False, + extension_scope=None, + serialized_options=None, + file=DESCRIPTOR, + ), + ], + extensions=[], + nested_types=[], + enum_types=[], + serialized_options=None, + is_extendable=False, + syntax="proto3", + extension_ranges=[], + oneofs=[ + _descriptor.OneofDescriptor( + name="source_info", + full_name="google.spanner.admin.database.v1.RestoreInfo.source_info", + index=0, + containing_type=None, + fields=[], + ) + ], + serialized_start=504, + serialized_end=675, +) + + _DATABASE = _descriptor.Descriptor( name="Database", full_name="google.spanner.admin.database.v1.Database", @@ -102,7 +211,7 @@ containing_type=None, is_extension=False, extension_scope=None, - serialized_options=None, + serialized_options=_b("\340A\002"), file=DESCRIPTOR, ), _descriptor.FieldDescriptor( @@ -120,7 +229,43 @@ containing_type=None, is_extension=False, extension_scope=None, - serialized_options=None, + serialized_options=_b("\340A\003"), + file=DESCRIPTOR, + ), + _descriptor.FieldDescriptor( + name="create_time", + full_name="google.spanner.admin.database.v1.Database.create_time", + index=2, + number=3, + type=11, + cpp_type=10, + label=1, + has_default_value=False, + default_value=None, + message_type=None, + enum_type=None, + containing_type=None, + is_extension=False, + extension_scope=None, + serialized_options=_b("\340A\003"), + file=DESCRIPTOR, + ), + _descriptor.FieldDescriptor( + name="restore_info", + full_name="google.spanner.admin.database.v1.Database.restore_info", + index=3, + number=4, + type=11, + cpp_type=10, + label=1, + has_default_value=False, + default_value=None, + message_type=None, + enum_type=None, + containing_type=None, + is_extension=False, + extension_scope=None, + serialized_options=_b("\340A\003"), file=DESCRIPTOR, ), ], @@ -134,8 +279,8 @@ syntax="proto3", extension_ranges=[], oneofs=[], - serialized_start=386, - serialized_end=632, + serialized_start=678, + serialized_end=1084, ) @@ -211,8 +356,8 @@ syntax="proto3", extension_ranges=[], oneofs=[], - serialized_start=634, - serialized_end=752, + serialized_start=1086, + serialized_end=1204, ) @@ -268,8 +413,8 @@ syntax="proto3", extension_ranges=[], oneofs=[], - serialized_start=754, - serialized_end=865, + serialized_start=1206, + serialized_end=1317, ) @@ -333,7 +478,7 @@ containing_type=None, is_extension=False, extension_scope=None, - serialized_options=None, + serialized_options=_b("\340A\001"), file=DESCRIPTOR, ), ], @@ -345,8 +490,8 @@ syntax="proto3", extension_ranges=[], oneofs=[], - serialized_start=868, - serialized_end=1005, + serialized_start=1320, + serialized_end=1462, ) @@ -384,8 +529,8 @@ syntax="proto3", extension_ranges=[], oneofs=[], - serialized_start=1007, - serialized_end=1087, + serialized_start=1464, + serialized_end=1544, ) @@ -425,8 +570,8 @@ syntax="proto3", extension_ranges=[], oneofs=[], - serialized_start=1089, - serialized_end=1164, + serialized_start=1546, + serialized_end=1621, ) @@ -502,8 +647,8 @@ syntax="proto3", extension_ranges=[], oneofs=[], - serialized_start=1167, - serialized_end=1299, + serialized_start=1624, + serialized_end=1756, ) @@ -577,8 +722,8 @@ syntax="proto3", extension_ranges=[], oneofs=[], - serialized_start=1302, - serialized_end=1460, + serialized_start=1759, + serialized_end=1917, ) @@ -618,8 +763,8 @@ syntax="proto3", extension_ranges=[], oneofs=[], - serialized_start=1462, - serialized_end=1542, + serialized_start=1919, + serialized_end=1999, ) @@ -659,8 +804,8 @@ syntax="proto3", extension_ranges=[], oneofs=[], - serialized_start=1544, - serialized_end=1626, + serialized_start=2001, + serialized_end=2083, ) @@ -698,80 +843,603 @@ syntax="proto3", extension_ranges=[], oneofs=[], - serialized_start=1628, - serialized_end=1672, + serialized_start=2085, + serialized_end=2129, ) -_DATABASE.fields_by_name["state"].enum_type = _DATABASE_STATE -_DATABASE_STATE.containing_type = _DATABASE -_LISTDATABASESRESPONSE.fields_by_name["databases"].message_type = _DATABASE -_UPDATEDATABASEDDLMETADATA.fields_by_name[ - "commit_timestamps" -].message_type = google_dot_protobuf_dot_timestamp__pb2._TIMESTAMP -DESCRIPTOR.message_types_by_name["Database"] = _DATABASE -DESCRIPTOR.message_types_by_name["ListDatabasesRequest"] = _LISTDATABASESREQUEST -DESCRIPTOR.message_types_by_name["ListDatabasesResponse"] = _LISTDATABASESRESPONSE -DESCRIPTOR.message_types_by_name["CreateDatabaseRequest"] = _CREATEDATABASEREQUEST -DESCRIPTOR.message_types_by_name["CreateDatabaseMetadata"] = _CREATEDATABASEMETADATA -DESCRIPTOR.message_types_by_name["GetDatabaseRequest"] = _GETDATABASEREQUEST -DESCRIPTOR.message_types_by_name["UpdateDatabaseDdlRequest"] = _UPDATEDATABASEDDLREQUEST -DESCRIPTOR.message_types_by_name[ - "UpdateDatabaseDdlMetadata" -] = _UPDATEDATABASEDDLMETADATA -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, - __module__="google.cloud.spanner.admin.database_v1.proto.spanner_database_admin_pb2", - __doc__="""A Cloud Spanner database. - - - Attributes: - name: - Required. The name of the database. Values are of the form ``p - rojects//instances//databases/``, - where ```` is as specified in the ``CREATE - DATABASE`` statement. This name can be passed to other API - methods to identify the database. - state: - Output only. The current database state. - """, - # @@protoc_insertion_point(class_scope:google.spanner.admin.database.v1.Database) - ), +_LISTDATABASEOPERATIONSREQUEST = _descriptor.Descriptor( + name="ListDatabaseOperationsRequest", + full_name="google.spanner.admin.database.v1.ListDatabaseOperationsRequest", + filename=None, + file=DESCRIPTOR, + containing_type=None, + fields=[ + _descriptor.FieldDescriptor( + name="parent", + full_name="google.spanner.admin.database.v1.ListDatabaseOperationsRequest.parent", + index=0, + number=1, + type=9, + cpp_type=9, + label=1, + has_default_value=False, + default_value=_b("").decode("utf-8"), + message_type=None, + enum_type=None, + containing_type=None, + is_extension=False, + extension_scope=None, + serialized_options=_b( + "\340A\002\372A!\n\037spanner.googleapis.com/Instance" + ), + file=DESCRIPTOR, + ), + _descriptor.FieldDescriptor( + name="filter", + full_name="google.spanner.admin.database.v1.ListDatabaseOperationsRequest.filter", + index=1, + number=2, + type=9, + cpp_type=9, + label=1, + has_default_value=False, + default_value=_b("").decode("utf-8"), + message_type=None, + enum_type=None, + containing_type=None, + is_extension=False, + extension_scope=None, + serialized_options=None, + file=DESCRIPTOR, + ), + _descriptor.FieldDescriptor( + name="page_size", + full_name="google.spanner.admin.database.v1.ListDatabaseOperationsRequest.page_size", + index=2, + number=3, + type=5, + cpp_type=1, + label=1, + has_default_value=False, + default_value=0, + message_type=None, + enum_type=None, + containing_type=None, + is_extension=False, + extension_scope=None, + serialized_options=None, + file=DESCRIPTOR, + ), + _descriptor.FieldDescriptor( + name="page_token", + full_name="google.spanner.admin.database.v1.ListDatabaseOperationsRequest.page_token", + index=3, + number=4, + type=9, + cpp_type=9, + label=1, + has_default_value=False, + default_value=_b("").decode("utf-8"), + message_type=None, + enum_type=None, + containing_type=None, + is_extension=False, + extension_scope=None, + serialized_options=None, + file=DESCRIPTOR, + ), + ], + extensions=[], + nested_types=[], + enum_types=[], + serialized_options=None, + is_extendable=False, + syntax="proto3", + extension_ranges=[], + oneofs=[], + serialized_start=2132, + serialized_end=2275, ) -_sym_db.RegisterMessage(Database) -ListDatabasesRequest = _reflection.GeneratedProtocolMessageType( - "ListDatabasesRequest", - (_message.Message,), - dict( - DESCRIPTOR=_LISTDATABASESREQUEST, - __module__="google.cloud.spanner.admin.database_v1.proto.spanner_database_admin_pb2", - __doc__="""The request for - [ListDatabases][google.spanner.admin.database.v1.DatabaseAdmin.ListDatabases]. - - - Attributes: - parent: - Required. The instance whose databases should be listed. - Values are of the form - ``projects//instances/``. - page_size: - Number of databases to be returned in the response. If 0 or - less, defaults to the server's maximum allowed page size. - page_token: - If non-empty, ``page_token`` should contain a [next\_page\_tok - en][google.spanner.admin.database.v1.ListDatabasesResponse.nex - t\_page\_token] from a previous [ListDatabasesResponse][google - .spanner.admin.database.v1.ListDatabasesResponse]. - """, - # @@protoc_insertion_point(class_scope:google.spanner.admin.database.v1.ListDatabasesRequest) + +_LISTDATABASEOPERATIONSRESPONSE = _descriptor.Descriptor( + name="ListDatabaseOperationsResponse", + full_name="google.spanner.admin.database.v1.ListDatabaseOperationsResponse", + filename=None, + file=DESCRIPTOR, + containing_type=None, + fields=[ + _descriptor.FieldDescriptor( + name="operations", + full_name="google.spanner.admin.database.v1.ListDatabaseOperationsResponse.operations", + index=0, + number=1, + type=11, + cpp_type=10, + label=3, + has_default_value=False, + default_value=[], + message_type=None, + enum_type=None, + containing_type=None, + is_extension=False, + extension_scope=None, + serialized_options=None, + file=DESCRIPTOR, + ), + _descriptor.FieldDescriptor( + name="next_page_token", + full_name="google.spanner.admin.database.v1.ListDatabaseOperationsResponse.next_page_token", + index=1, + number=2, + type=9, + cpp_type=9, + label=1, + has_default_value=False, + default_value=_b("").decode("utf-8"), + message_type=None, + enum_type=None, + containing_type=None, + is_extension=False, + extension_scope=None, + serialized_options=None, + file=DESCRIPTOR, + ), + ], + extensions=[], + nested_types=[], + enum_types=[], + serialized_options=None, + is_extendable=False, + syntax="proto3", + extension_ranges=[], + oneofs=[], + serialized_start=2277, + serialized_end=2385, +) + + +_RESTOREDATABASEREQUEST = _descriptor.Descriptor( + name="RestoreDatabaseRequest", + full_name="google.spanner.admin.database.v1.RestoreDatabaseRequest", + filename=None, + file=DESCRIPTOR, + containing_type=None, + fields=[ + _descriptor.FieldDescriptor( + name="parent", + full_name="google.spanner.admin.database.v1.RestoreDatabaseRequest.parent", + index=0, + number=1, + type=9, + cpp_type=9, + label=1, + has_default_value=False, + default_value=_b("").decode("utf-8"), + message_type=None, + enum_type=None, + containing_type=None, + is_extension=False, + extension_scope=None, + serialized_options=_b( + "\340A\002\372A!\n\037spanner.googleapis.com/Instance" + ), + file=DESCRIPTOR, + ), + _descriptor.FieldDescriptor( + name="database_id", + full_name="google.spanner.admin.database.v1.RestoreDatabaseRequest.database_id", + index=1, + number=2, + type=9, + cpp_type=9, + label=1, + has_default_value=False, + default_value=_b("").decode("utf-8"), + message_type=None, + enum_type=None, + containing_type=None, + is_extension=False, + extension_scope=None, + serialized_options=_b("\340A\002"), + file=DESCRIPTOR, + ), + _descriptor.FieldDescriptor( + name="backup", + full_name="google.spanner.admin.database.v1.RestoreDatabaseRequest.backup", + index=2, + number=3, + type=9, + cpp_type=9, + label=1, + has_default_value=False, + default_value=_b("").decode("utf-8"), + message_type=None, + enum_type=None, + containing_type=None, + is_extension=False, + extension_scope=None, + serialized_options=_b("\372A\037\n\035spanner.googleapis.com/Backup"), + file=DESCRIPTOR, + ), + ], + extensions=[], + nested_types=[], + enum_types=[], + serialized_options=None, + is_extendable=False, + syntax="proto3", + extension_ranges=[], + oneofs=[ + _descriptor.OneofDescriptor( + name="source", + full_name="google.spanner.admin.database.v1.RestoreDatabaseRequest.source", + index=0, + containing_type=None, + fields=[], + ) + ], + serialized_start=2388, + serialized_end=2559, +) + + +_RESTOREDATABASEMETADATA = _descriptor.Descriptor( + name="RestoreDatabaseMetadata", + full_name="google.spanner.admin.database.v1.RestoreDatabaseMetadata", + filename=None, + file=DESCRIPTOR, + containing_type=None, + fields=[ + _descriptor.FieldDescriptor( + name="name", + full_name="google.spanner.admin.database.v1.RestoreDatabaseMetadata.name", + index=0, + number=1, + type=9, + cpp_type=9, + label=1, + has_default_value=False, + default_value=_b("").decode("utf-8"), + message_type=None, + enum_type=None, + containing_type=None, + is_extension=False, + extension_scope=None, + serialized_options=None, + file=DESCRIPTOR, + ), + _descriptor.FieldDescriptor( + name="source_type", + full_name="google.spanner.admin.database.v1.RestoreDatabaseMetadata.source_type", + index=1, + number=2, + type=14, + cpp_type=8, + label=1, + has_default_value=False, + default_value=0, + message_type=None, + enum_type=None, + containing_type=None, + is_extension=False, + extension_scope=None, + serialized_options=None, + file=DESCRIPTOR, + ), + _descriptor.FieldDescriptor( + name="backup_info", + full_name="google.spanner.admin.database.v1.RestoreDatabaseMetadata.backup_info", + index=2, + number=3, + type=11, + cpp_type=10, + label=1, + has_default_value=False, + default_value=None, + message_type=None, + enum_type=None, + containing_type=None, + is_extension=False, + extension_scope=None, + serialized_options=None, + file=DESCRIPTOR, + ), + _descriptor.FieldDescriptor( + name="progress", + full_name="google.spanner.admin.database.v1.RestoreDatabaseMetadata.progress", + index=3, + number=4, + type=11, + cpp_type=10, + label=1, + has_default_value=False, + default_value=None, + message_type=None, + enum_type=None, + containing_type=None, + is_extension=False, + extension_scope=None, + serialized_options=None, + file=DESCRIPTOR, + ), + _descriptor.FieldDescriptor( + name="cancel_time", + full_name="google.spanner.admin.database.v1.RestoreDatabaseMetadata.cancel_time", + 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, + serialized_options=None, + file=DESCRIPTOR, + ), + _descriptor.FieldDescriptor( + name="optimize_database_operation_name", + full_name="google.spanner.admin.database.v1.RestoreDatabaseMetadata.optimize_database_operation_name", + index=5, + number=6, + type=9, + cpp_type=9, + label=1, + has_default_value=False, + default_value=_b("").decode("utf-8"), + message_type=None, + enum_type=None, + containing_type=None, + is_extension=False, + extension_scope=None, + serialized_options=None, + file=DESCRIPTOR, + ), + ], + extensions=[], + nested_types=[], + enum_types=[], + serialized_options=None, + is_extendable=False, + syntax="proto3", + extension_ranges=[], + oneofs=[ + _descriptor.OneofDescriptor( + name="source_info", + full_name="google.spanner.admin.database.v1.RestoreDatabaseMetadata.source_info", + index=0, + containing_type=None, + fields=[], + ) + ], + serialized_start=2562, + serialized_end=2921, +) + + +_OPTIMIZERESTOREDDATABASEMETADATA = _descriptor.Descriptor( + name="OptimizeRestoredDatabaseMetadata", + full_name="google.spanner.admin.database.v1.OptimizeRestoredDatabaseMetadata", + filename=None, + file=DESCRIPTOR, + containing_type=None, + fields=[ + _descriptor.FieldDescriptor( + name="name", + full_name="google.spanner.admin.database.v1.OptimizeRestoredDatabaseMetadata.name", + index=0, + number=1, + type=9, + cpp_type=9, + label=1, + has_default_value=False, + default_value=_b("").decode("utf-8"), + message_type=None, + enum_type=None, + containing_type=None, + is_extension=False, + extension_scope=None, + serialized_options=None, + file=DESCRIPTOR, + ), + _descriptor.FieldDescriptor( + name="progress", + full_name="google.spanner.admin.database.v1.OptimizeRestoredDatabaseMetadata.progress", + index=1, + number=2, + type=11, + cpp_type=10, + label=1, + has_default_value=False, + default_value=None, + message_type=None, + enum_type=None, + containing_type=None, + is_extension=False, + extension_scope=None, + serialized_options=None, + file=DESCRIPTOR, + ), + ], + extensions=[], + nested_types=[], + enum_types=[], + serialized_options=None, + is_extendable=False, + syntax="proto3", + extension_ranges=[], + oneofs=[], + serialized_start=2923, + serialized_end=3042, +) + +_RESTOREINFO.fields_by_name["source_type"].enum_type = _RESTORESOURCETYPE +_RESTOREINFO.fields_by_name[ + "backup_info" +].message_type = ( + google_dot_cloud_dot_spanner_dot_admin_dot_database__v1_dot_proto_dot_backup__pb2._BACKUPINFO +) +_RESTOREINFO.oneofs_by_name["source_info"].fields.append( + _RESTOREINFO.fields_by_name["backup_info"] +) +_RESTOREINFO.fields_by_name[ + "backup_info" +].containing_oneof = _RESTOREINFO.oneofs_by_name["source_info"] +_DATABASE.fields_by_name["state"].enum_type = _DATABASE_STATE +_DATABASE.fields_by_name[ + "create_time" +].message_type = google_dot_protobuf_dot_timestamp__pb2._TIMESTAMP +_DATABASE.fields_by_name["restore_info"].message_type = _RESTOREINFO +_DATABASE_STATE.containing_type = _DATABASE +_LISTDATABASESRESPONSE.fields_by_name["databases"].message_type = _DATABASE +_UPDATEDATABASEDDLMETADATA.fields_by_name[ + "commit_timestamps" +].message_type = google_dot_protobuf_dot_timestamp__pb2._TIMESTAMP +_LISTDATABASEOPERATIONSRESPONSE.fields_by_name[ + "operations" +].message_type = google_dot_longrunning_dot_operations__pb2._OPERATION +_RESTOREDATABASEREQUEST.oneofs_by_name["source"].fields.append( + _RESTOREDATABASEREQUEST.fields_by_name["backup"] +) +_RESTOREDATABASEREQUEST.fields_by_name[ + "backup" +].containing_oneof = _RESTOREDATABASEREQUEST.oneofs_by_name["source"] +_RESTOREDATABASEMETADATA.fields_by_name["source_type"].enum_type = _RESTORESOURCETYPE +_RESTOREDATABASEMETADATA.fields_by_name[ + "backup_info" +].message_type = ( + google_dot_cloud_dot_spanner_dot_admin_dot_database__v1_dot_proto_dot_backup__pb2._BACKUPINFO +) +_RESTOREDATABASEMETADATA.fields_by_name[ + "progress" +].message_type = ( + google_dot_cloud_dot_spanner_dot_admin_dot_database__v1_dot_proto_dot_common__pb2._OPERATIONPROGRESS +) +_RESTOREDATABASEMETADATA.fields_by_name[ + "cancel_time" +].message_type = google_dot_protobuf_dot_timestamp__pb2._TIMESTAMP +_RESTOREDATABASEMETADATA.oneofs_by_name["source_info"].fields.append( + _RESTOREDATABASEMETADATA.fields_by_name["backup_info"] +) +_RESTOREDATABASEMETADATA.fields_by_name[ + "backup_info" +].containing_oneof = _RESTOREDATABASEMETADATA.oneofs_by_name["source_info"] +_OPTIMIZERESTOREDDATABASEMETADATA.fields_by_name[ + "progress" +].message_type = ( + google_dot_cloud_dot_spanner_dot_admin_dot_database__v1_dot_proto_dot_common__pb2._OPERATIONPROGRESS +) +DESCRIPTOR.message_types_by_name["RestoreInfo"] = _RESTOREINFO +DESCRIPTOR.message_types_by_name["Database"] = _DATABASE +DESCRIPTOR.message_types_by_name["ListDatabasesRequest"] = _LISTDATABASESREQUEST +DESCRIPTOR.message_types_by_name["ListDatabasesResponse"] = _LISTDATABASESRESPONSE +DESCRIPTOR.message_types_by_name["CreateDatabaseRequest"] = _CREATEDATABASEREQUEST +DESCRIPTOR.message_types_by_name["CreateDatabaseMetadata"] = _CREATEDATABASEMETADATA +DESCRIPTOR.message_types_by_name["GetDatabaseRequest"] = _GETDATABASEREQUEST +DESCRIPTOR.message_types_by_name["UpdateDatabaseDdlRequest"] = _UPDATEDATABASEDDLREQUEST +DESCRIPTOR.message_types_by_name[ + "UpdateDatabaseDdlMetadata" +] = _UPDATEDATABASEDDLMETADATA +DESCRIPTOR.message_types_by_name["DropDatabaseRequest"] = _DROPDATABASEREQUEST +DESCRIPTOR.message_types_by_name["GetDatabaseDdlRequest"] = _GETDATABASEDDLREQUEST +DESCRIPTOR.message_types_by_name["GetDatabaseDdlResponse"] = _GETDATABASEDDLRESPONSE +DESCRIPTOR.message_types_by_name[ + "ListDatabaseOperationsRequest" +] = _LISTDATABASEOPERATIONSREQUEST +DESCRIPTOR.message_types_by_name[ + "ListDatabaseOperationsResponse" +] = _LISTDATABASEOPERATIONSRESPONSE +DESCRIPTOR.message_types_by_name["RestoreDatabaseRequest"] = _RESTOREDATABASEREQUEST +DESCRIPTOR.message_types_by_name["RestoreDatabaseMetadata"] = _RESTOREDATABASEMETADATA +DESCRIPTOR.message_types_by_name[ + "OptimizeRestoredDatabaseMetadata" +] = _OPTIMIZERESTOREDDATABASEMETADATA +DESCRIPTOR.enum_types_by_name["RestoreSourceType"] = _RESTORESOURCETYPE +_sym_db.RegisterFileDescriptor(DESCRIPTOR) + +RestoreInfo = _reflection.GeneratedProtocolMessageType( + "RestoreInfo", + (_message.Message,), + dict( + DESCRIPTOR=_RESTOREINFO, + __module__="google.cloud.spanner.admin.database_v1.proto.spanner_database_admin_pb2", + __doc__="""Information about the database restore. + + + Attributes: + source_type: + The type of the restore source. + source_info: + Information about the source used to restore the database. + backup_info: + Information about the backup used to restore the database. The + backup may no longer exist. + """, + # @@protoc_insertion_point(class_scope:google.spanner.admin.database.v1.RestoreInfo) + ), +) +_sym_db.RegisterMessage(RestoreInfo) + +Database = _reflection.GeneratedProtocolMessageType( + "Database", + (_message.Message,), + dict( + DESCRIPTOR=_DATABASE, + __module__="google.cloud.spanner.admin.database_v1.proto.spanner_database_admin_pb2", + __doc__="""A Cloud Spanner database. + + + Attributes: + name: + Required. The name of the database. Values are of the form ``p + rojects//instances//databases/``, + where ```` is as specified in the ``CREATE + DATABASE`` statement. This name can be passed to other API + methods to identify the database. + state: + Output only. The current database state. + create_time: + Output only. If exists, the time at which the database + creation started. + restore_info: + Output only. Applicable only for restored databases. Contains + information about the restore source. + """, + # @@protoc_insertion_point(class_scope:google.spanner.admin.database.v1.Database) + ), +) +_sym_db.RegisterMessage(Database) + +ListDatabasesRequest = _reflection.GeneratedProtocolMessageType( + "ListDatabasesRequest", + (_message.Message,), + dict( + DESCRIPTOR=_LISTDATABASESREQUEST, + __module__="google.cloud.spanner.admin.database_v1.proto.spanner_database_admin_pb2", + __doc__="""The request for + [ListDatabases][google.spanner.admin.database.v1.DatabaseAdmin.ListDatabases]. + + + Attributes: + parent: + Required. The instance whose databases should be listed. + Values are of the form + ``projects//instances/``. + page_size: + Number of databases to be returned in the response. If 0 or + less, defaults to the server's maximum allowed page size. + page_token: + If non-empty, ``page_token`` should contain a [next\_page\_tok + en][google.spanner.admin.database.v1.ListDatabasesResponse.nex + t\_page\_token] from a previous [ListDatabasesResponse][google + .spanner.admin.database.v1.ListDatabasesResponse]. + """, + # @@protoc_insertion_point(class_scope:google.spanner.admin.database.v1.ListDatabasesRequest) ), ) _sym_db.RegisterMessage(ListDatabasesRequest) @@ -822,7 +1490,7 @@ reserved word or if it contains a hyphen, the database ID must be enclosed in backticks (`````). extra_statements: - An optional list of DDL statements to run inside the newly + Optional. A list of DDL statements to run inside the newly created database. Statements can create tables, indexes, etc. These statements execute atomically with the creation of the database: if there is an error in any statement, the database @@ -1013,12 +1681,230 @@ ) _sym_db.RegisterMessage(GetDatabaseDdlResponse) +ListDatabaseOperationsRequest = _reflection.GeneratedProtocolMessageType( + "ListDatabaseOperationsRequest", + (_message.Message,), + dict( + DESCRIPTOR=_LISTDATABASEOPERATIONSREQUEST, + __module__="google.cloud.spanner.admin.database_v1.proto.spanner_database_admin_pb2", + __doc__="""The request for + [ListDatabaseOperations][google.spanner.admin.database.v1.DatabaseAdmin.ListDatabaseOperations]. + + + Attributes: + parent: + Required. The instance of the database operations. Values are + of the form ``projects//instances/``. + filter: + An expression that filters the list of returned operations. A + filter expression consists of a field name, a comparison + operator, and a value for filtering. The value must be a + string, a number, or a boolean. The comparison operator must + be one of: ``<``, ``>``, ``<=``, ``>=``, ``!=``, ``=``, or + ``:``. Colon ``:`` is the contains operator. Filter rules are + not case sensitive. The following fields in the + [Operation][google.longrunning.Operation] are eligible for + filtering: - ``name`` - The name of the long-running + operation - ``done`` - False if the operation is in progress, + else true. - ``metadata.@type`` - the type of metadata. For + example, the type string for [RestoreDatabaseMetadata][g + oogle.spanner.admin.database.v1.RestoreDatabaseMetadata] is + ``type.googleapis.com/google.spanner.admin.database.v1.Restore + DatabaseMetadata``. - ``metadata.`` - any field + in metadata.value. - ``error`` - Error associated with the + long-running operation. - ``response.@type`` - the type of + response. - ``response.`` - any field in + response.value. You can combine multiple expressions by + enclosing each expression in parentheses. By default, + expressions are combined with AND logic. However, you can + specify AND, OR, and NOT logic explicitly. Here are a few + examples: - ``done:true`` - The operation is complete. - `` + (metadata.@type=type.googleapis.com/google.spanner.admin.datab + ase.v1.RestoreDatabaseMetadata) AND`` + ``(metadata.source_type:BACKUP) AND`` + ``(metadata.backup_info.backup:backup_howl) AND`` + ``(metadata.name:restored_howl) AND`` + ``(metadata.progress.start_time < \"2018-03-28T14:50:00Z\") + AND`` ``(error:*)`` - Return operations where: - The + operation's metadata type is [RestoreDatabaseMetadata][g + oogle.spanner.admin.database.v1.RestoreDatabaseMetadata]. - + The database is restored from a backup. - The backup name + contains "backup\_howl". - The restored database's name + contains "restored\_howl". - The operation started before + 2018-03-28T14:50:00Z. - The operation resulted in an + error. + page_size: + Number of operations to be returned in the response. If 0 or + less, defaults to the server's maximum allowed page size. + page_token: + If non-empty, ``page_token`` should contain a [next\_page\_tok + en][google.spanner.admin.database.v1.ListDatabaseOperationsRes + ponse.next\_page\_token] from a previous [ListDatabaseOperatio + nsResponse][google.spanner.admin.database.v1.ListDatabaseOpera + tionsResponse] to the same ``parent`` and with the same + ``filter``. + """, + # @@protoc_insertion_point(class_scope:google.spanner.admin.database.v1.ListDatabaseOperationsRequest) + ), +) +_sym_db.RegisterMessage(ListDatabaseOperationsRequest) + +ListDatabaseOperationsResponse = _reflection.GeneratedProtocolMessageType( + "ListDatabaseOperationsResponse", + (_message.Message,), + dict( + DESCRIPTOR=_LISTDATABASEOPERATIONSRESPONSE, + __module__="google.cloud.spanner.admin.database_v1.proto.spanner_database_admin_pb2", + __doc__="""The response for + [ListDatabaseOperations][google.spanner.admin.database.v1.DatabaseAdmin.ListDatabaseOperations]. + + + Attributes: + operations: + The list of matching database [long-running + operations][google.longrunning.Operation]. Each operation's + name will be prefixed by the database's name. The operation's + [metadata][google.longrunning.Operation.metadata] field type + ``metadata.type_url`` describes the type of the metadata. + next_page_token: + \ ``next_page_token`` can be sent in a subsequent [ListDatabas + eOperations][google.spanner.admin.database.v1.DatabaseAdmin.Li + stDatabaseOperations] call to fetch more of the matching + metadata. + """, + # @@protoc_insertion_point(class_scope:google.spanner.admin.database.v1.ListDatabaseOperationsResponse) + ), +) +_sym_db.RegisterMessage(ListDatabaseOperationsResponse) + +RestoreDatabaseRequest = _reflection.GeneratedProtocolMessageType( + "RestoreDatabaseRequest", + (_message.Message,), + dict( + DESCRIPTOR=_RESTOREDATABASEREQUEST, + __module__="google.cloud.spanner.admin.database_v1.proto.spanner_database_admin_pb2", + __doc__="""The request for + [RestoreDatabase][google.spanner.admin.database.v1.DatabaseAdmin.RestoreDatabase]. + + + Attributes: + parent: + Required. The name of the instance in which to create the + restored database. This instance must be in the same project + and have the same instance configuration as the instance + containing the source backup. Values are of the form + ``projects//instances/``. + database_id: + Required. The id of the database to create and restore to. + This database must not already exist. The ``database_id`` + appended to ``parent`` forms the full database name of the + form ``projects//instances//databases/``. + source: + Required. The source from which to restore. + backup: + Name of the backup from which to restore. Values are of the + form + ``projects//instances//backups/``. + """, + # @@protoc_insertion_point(class_scope:google.spanner.admin.database.v1.RestoreDatabaseRequest) + ), +) +_sym_db.RegisterMessage(RestoreDatabaseRequest) + +RestoreDatabaseMetadata = _reflection.GeneratedProtocolMessageType( + "RestoreDatabaseMetadata", + (_message.Message,), + dict( + DESCRIPTOR=_RESTOREDATABASEMETADATA, + __module__="google.cloud.spanner.admin.database_v1.proto.spanner_database_admin_pb2", + __doc__="""Metadata type for the long-running operation returned by + [RestoreDatabase][google.spanner.admin.database.v1.DatabaseAdmin.RestoreDatabase]. + + + Attributes: + name: + Name of the database being created and restored to. + source_type: + The type of the restore source. + source_info: + Information about the source used to restore the database, as + specified by ``source`` in [RestoreDatabaseRequest][google.spa + nner.admin.database.v1.RestoreDatabaseRequest]. + backup_info: + Information about the backup used to restore the database. + progress: + The progress of the [RestoreDatabase][google.spanner.admin.dat + abase.v1.DatabaseAdmin.RestoreDatabase] operation. + cancel_time: + The time at which cancellation of this operation was received. + [Operations.CancelOperation][google.longrunning.Operations.Can + celOperation] starts asynchronous cancellation on a long- + running operation. The server makes a best effort to cancel + the operation, but success is not guaranteed. Clients can use + [Operations.GetOperation][google.longrunning.Operations.GetOpe + ration] or other methods to check whether the cancellation + succeeded or whether the operation completed despite + cancellation. On successful cancellation, the operation is not + deleted; instead, it becomes an operation with an + [Operation.error][google.longrunning.Operation.error] value + with a [google.rpc.Status.code][google.rpc.Status.code] of 1, + corresponding to ``Code.CANCELLED``. + optimize_database_operation_name: + If exists, the name of the long-running operation that will be + used to track the post-restore optimization process to + optimize the performance of the restored database, and remove + the dependency on the restore source. The name is of the form + ``projects//instances//databases/ + /operations/`` where the is the name of database + being created and restored to. The metadata type of the long- + running operation is [OptimizeRestoredDatabaseMetadata][google + .spanner.admin.database.v1.OptimizeRestoredDatabaseMetadata]. + This long-running operation will be automatically created by + the system after the RestoreDatabase long-running operation + completes successfully. This operation will not be created if + the restore was not successful. + """, + # @@protoc_insertion_point(class_scope:google.spanner.admin.database.v1.RestoreDatabaseMetadata) + ), +) +_sym_db.RegisterMessage(RestoreDatabaseMetadata) + +OptimizeRestoredDatabaseMetadata = _reflection.GeneratedProtocolMessageType( + "OptimizeRestoredDatabaseMetadata", + (_message.Message,), + dict( + DESCRIPTOR=_OPTIMIZERESTOREDDATABASEMETADATA, + __module__="google.cloud.spanner.admin.database_v1.proto.spanner_database_admin_pb2", + __doc__="""Metadata type for the long-running operation used to track + the progress of optimizations performed on a newly restored database. + This long-running operation is automatically created by the system after + the successful completion of a database restore, and cannot be + cancelled. + + + Attributes: + name: + Name of the restored database being optimized. + progress: + The progress of the post-restore optimizations. + """, + # @@protoc_insertion_point(class_scope:google.spanner.admin.database.v1.OptimizeRestoredDatabaseMetadata) + ), +) +_sym_db.RegisterMessage(OptimizeRestoredDatabaseMetadata) + DESCRIPTOR._options = None +_DATABASE.fields_by_name["name"]._options = None +_DATABASE.fields_by_name["state"]._options = None +_DATABASE.fields_by_name["create_time"]._options = None +_DATABASE.fields_by_name["restore_info"]._options = None _DATABASE._options = None _LISTDATABASESREQUEST.fields_by_name["parent"]._options = None _CREATEDATABASEREQUEST.fields_by_name["parent"]._options = None _CREATEDATABASEREQUEST.fields_by_name["create_statement"]._options = None +_CREATEDATABASEREQUEST.fields_by_name["extra_statements"]._options = None _CREATEDATABASEMETADATA.fields_by_name["database"]._options = None _GETDATABASEREQUEST.fields_by_name["name"]._options = None _UPDATEDATABASEDDLREQUEST.fields_by_name["database"]._options = None @@ -1026,6 +1912,10 @@ _UPDATEDATABASEDDLMETADATA.fields_by_name["database"]._options = None _DROPDATABASEREQUEST.fields_by_name["database"]._options = None _GETDATABASEDDLREQUEST.fields_by_name["database"]._options = None +_LISTDATABASEOPERATIONSREQUEST.fields_by_name["parent"]._options = None +_RESTOREDATABASEREQUEST.fields_by_name["parent"]._options = None +_RESTOREDATABASEREQUEST.fields_by_name["database_id"]._options = None +_RESTOREDATABASEREQUEST.fields_by_name["backup"]._options = None _DATABASEADMIN = _descriptor.ServiceDescriptor( name="DatabaseAdmin", @@ -1035,8 +1925,8 @@ serialized_options=_b( "\312A\026spanner.googleapis.com\322A\\https://www.googleapis.com/auth/cloud-platform,https://www.googleapis.com/auth/spanner.admin" ), - serialized_start=1675, - serialized_end=3896, + serialized_start=3100, + serialized_end=7054, methods=[ _descriptor.MethodDescriptor( name="ListDatabases", @@ -1137,6 +2027,94 @@ '\202\323\344\223\002\222\001"D/v1/{resource=projects/*/instances/*/databases/*}:testIamPermissions:\001*ZG"B/v1/{resource=projects/*/instances/*/backups/*}:testIamPermissions:\001*\332A\024resource,permissions' ), ), + _descriptor.MethodDescriptor( + name="CreateBackup", + full_name="google.spanner.admin.database.v1.DatabaseAdmin.CreateBackup", + index=9, + containing_service=None, + input_type=google_dot_cloud_dot_spanner_dot_admin_dot_database__v1_dot_proto_dot_backup__pb2._CREATEBACKUPREQUEST, + output_type=google_dot_longrunning_dot_operations__pb2._OPERATION, + serialized_options=_b( + '\202\323\344\223\0025"+/v1/{parent=projects/*/instances/*}/backups:\006backup\332A\027parent,backup,backup_id\312A?\n\006Backup\0225google.spanner.admin.database.v1.CreateBackupMetadata' + ), + ), + _descriptor.MethodDescriptor( + name="GetBackup", + full_name="google.spanner.admin.database.v1.DatabaseAdmin.GetBackup", + index=10, + containing_service=None, + input_type=google_dot_cloud_dot_spanner_dot_admin_dot_database__v1_dot_proto_dot_backup__pb2._GETBACKUPREQUEST, + output_type=google_dot_cloud_dot_spanner_dot_admin_dot_database__v1_dot_proto_dot_backup__pb2._BACKUP, + serialized_options=_b( + "\202\323\344\223\002-\022+/v1/{name=projects/*/instances/*/backups/*}\332A\004name" + ), + ), + _descriptor.MethodDescriptor( + name="UpdateBackup", + full_name="google.spanner.admin.database.v1.DatabaseAdmin.UpdateBackup", + index=11, + containing_service=None, + input_type=google_dot_cloud_dot_spanner_dot_admin_dot_database__v1_dot_proto_dot_backup__pb2._UPDATEBACKUPREQUEST, + output_type=google_dot_cloud_dot_spanner_dot_admin_dot_database__v1_dot_proto_dot_backup__pb2._BACKUP, + serialized_options=_b( + "\202\323\344\223\002<22/v1/{backup.name=projects/*/instances/*/backups/*}:\006backup\332A\022backup,update_mask" + ), + ), + _descriptor.MethodDescriptor( + name="DeleteBackup", + full_name="google.spanner.admin.database.v1.DatabaseAdmin.DeleteBackup", + index=12, + containing_service=None, + input_type=google_dot_cloud_dot_spanner_dot_admin_dot_database__v1_dot_proto_dot_backup__pb2._DELETEBACKUPREQUEST, + output_type=google_dot_protobuf_dot_empty__pb2._EMPTY, + serialized_options=_b( + "\202\323\344\223\002-*+/v1/{name=projects/*/instances/*/backups/*}\332A\004name" + ), + ), + _descriptor.MethodDescriptor( + name="ListBackups", + full_name="google.spanner.admin.database.v1.DatabaseAdmin.ListBackups", + index=13, + containing_service=None, + input_type=google_dot_cloud_dot_spanner_dot_admin_dot_database__v1_dot_proto_dot_backup__pb2._LISTBACKUPSREQUEST, + output_type=google_dot_cloud_dot_spanner_dot_admin_dot_database__v1_dot_proto_dot_backup__pb2._LISTBACKUPSRESPONSE, + serialized_options=_b( + "\202\323\344\223\002-\022+/v1/{parent=projects/*/instances/*}/backups\332A\006parent" + ), + ), + _descriptor.MethodDescriptor( + name="RestoreDatabase", + full_name="google.spanner.admin.database.v1.DatabaseAdmin.RestoreDatabase", + index=14, + containing_service=None, + input_type=_RESTOREDATABASEREQUEST, + output_type=google_dot_longrunning_dot_operations__pb2._OPERATION, + serialized_options=_b( + '\202\323\344\223\002:"5/v1/{parent=projects/*/instances/*}/databases:restore:\001*\332A\031parent,database_id,backup\312Ae\n)google.spanner.admin.database.v1.Database\0228google.spanner.admin.database.v1.RestoreDatabaseMetadata' + ), + ), + _descriptor.MethodDescriptor( + name="ListDatabaseOperations", + full_name="google.spanner.admin.database.v1.DatabaseAdmin.ListDatabaseOperations", + index=15, + containing_service=None, + input_type=_LISTDATABASEOPERATIONSREQUEST, + output_type=_LISTDATABASEOPERATIONSRESPONSE, + serialized_options=_b( + "\202\323\344\223\0028\0226/v1/{parent=projects/*/instances/*}/databaseOperations\332A\006parent" + ), + ), + _descriptor.MethodDescriptor( + name="ListBackupOperations", + full_name="google.spanner.admin.database.v1.DatabaseAdmin.ListBackupOperations", + index=16, + containing_service=None, + input_type=google_dot_cloud_dot_spanner_dot_admin_dot_database__v1_dot_proto_dot_backup__pb2._LISTBACKUPOPERATIONSREQUEST, + output_type=google_dot_cloud_dot_spanner_dot_admin_dot_database__v1_dot_proto_dot_backup__pb2._LISTBACKUPOPERATIONSRESPONSE, + serialized_options=_b( + "\202\323\344\223\0026\0224/v1/{parent=projects/*/instances/*}/backupOperations\332A\006parent" + ), + ), ], ) _sym_db.RegisterServiceDescriptor(_DATABASEADMIN) diff --git a/google/cloud/spanner_admin_database_v1/proto/spanner_database_admin_pb2_grpc.py b/google/cloud/spanner_admin_database_v1/proto/spanner_database_admin_pb2_grpc.py index 7ea7ddb6fa..8ecb673158 100644 --- a/google/cloud/spanner_admin_database_v1/proto/spanner_database_admin_pb2_grpc.py +++ b/google/cloud/spanner_admin_database_v1/proto/spanner_database_admin_pb2_grpc.py @@ -1,6 +1,9 @@ # Generated by the gRPC Python protocol compiler plugin. DO NOT EDIT! import grpc +from google.cloud.spanner_admin_database_v1.proto import ( + backup_pb2 as google_dot_cloud_dot_spanner_dot_admin_dot_database__v1_dot_proto_dot_backup__pb2, +) from google.cloud.spanner_admin_database_v1.proto import ( spanner_database_admin_pb2 as google_dot_cloud_dot_spanner_dot_admin_dot_database__v1_dot_proto_dot_spanner__database__admin__pb2, ) @@ -17,7 +20,8 @@ class DatabaseAdminStub(object): 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. + databases. It can be also used to create, delete and list backups for a + database and to restore from an existing backup. """ def __init__(self, channel): @@ -71,6 +75,46 @@ def __init__(self, channel): 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, ) + self.CreateBackup = channel.unary_unary( + "/google.spanner.admin.database.v1.DatabaseAdmin/CreateBackup", + request_serializer=google_dot_cloud_dot_spanner_dot_admin_dot_database__v1_dot_proto_dot_backup__pb2.CreateBackupRequest.SerializeToString, + response_deserializer=google_dot_longrunning_dot_operations__pb2.Operation.FromString, + ) + self.GetBackup = channel.unary_unary( + "/google.spanner.admin.database.v1.DatabaseAdmin/GetBackup", + request_serializer=google_dot_cloud_dot_spanner_dot_admin_dot_database__v1_dot_proto_dot_backup__pb2.GetBackupRequest.SerializeToString, + response_deserializer=google_dot_cloud_dot_spanner_dot_admin_dot_database__v1_dot_proto_dot_backup__pb2.Backup.FromString, + ) + self.UpdateBackup = channel.unary_unary( + "/google.spanner.admin.database.v1.DatabaseAdmin/UpdateBackup", + request_serializer=google_dot_cloud_dot_spanner_dot_admin_dot_database__v1_dot_proto_dot_backup__pb2.UpdateBackupRequest.SerializeToString, + response_deserializer=google_dot_cloud_dot_spanner_dot_admin_dot_database__v1_dot_proto_dot_backup__pb2.Backup.FromString, + ) + self.DeleteBackup = channel.unary_unary( + "/google.spanner.admin.database.v1.DatabaseAdmin/DeleteBackup", + request_serializer=google_dot_cloud_dot_spanner_dot_admin_dot_database__v1_dot_proto_dot_backup__pb2.DeleteBackupRequest.SerializeToString, + response_deserializer=google_dot_protobuf_dot_empty__pb2.Empty.FromString, + ) + self.ListBackups = channel.unary_unary( + "/google.spanner.admin.database.v1.DatabaseAdmin/ListBackups", + request_serializer=google_dot_cloud_dot_spanner_dot_admin_dot_database__v1_dot_proto_dot_backup__pb2.ListBackupsRequest.SerializeToString, + response_deserializer=google_dot_cloud_dot_spanner_dot_admin_dot_database__v1_dot_proto_dot_backup__pb2.ListBackupsResponse.FromString, + ) + self.RestoreDatabase = channel.unary_unary( + "/google.spanner.admin.database.v1.DatabaseAdmin/RestoreDatabase", + request_serializer=google_dot_cloud_dot_spanner_dot_admin_dot_database__v1_dot_proto_dot_spanner__database__admin__pb2.RestoreDatabaseRequest.SerializeToString, + response_deserializer=google_dot_longrunning_dot_operations__pb2.Operation.FromString, + ) + self.ListDatabaseOperations = channel.unary_unary( + "/google.spanner.admin.database.v1.DatabaseAdmin/ListDatabaseOperations", + request_serializer=google_dot_cloud_dot_spanner_dot_admin_dot_database__v1_dot_proto_dot_spanner__database__admin__pb2.ListDatabaseOperationsRequest.SerializeToString, + response_deserializer=google_dot_cloud_dot_spanner_dot_admin_dot_database__v1_dot_proto_dot_spanner__database__admin__pb2.ListDatabaseOperationsResponse.FromString, + ) + self.ListBackupOperations = channel.unary_unary( + "/google.spanner.admin.database.v1.DatabaseAdmin/ListBackupOperations", + request_serializer=google_dot_cloud_dot_spanner_dot_admin_dot_database__v1_dot_proto_dot_backup__pb2.ListBackupOperationsRequest.SerializeToString, + response_deserializer=google_dot_cloud_dot_spanner_dot_admin_dot_database__v1_dot_proto_dot_backup__pb2.ListBackupOperationsResponse.FromString, + ) class DatabaseAdminServicer(object): @@ -78,7 +122,8 @@ class DatabaseAdminServicer(object): 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. + databases. It can be also used to create, delete and list backups for a + database and to restore from an existing backup. """ def ListDatabases(self, request, context): @@ -94,8 +139,8 @@ def CreateDatabase(self, request, context): 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 + [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) @@ -116,8 +161,7 @@ def UpdateDatabaseDdl(self, request, context): 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. + [UpdateDatabaseDdlMetadata][google.spanner.admin.database.v1.UpdateDatabaseDdlMetadata]. The operation has no response. """ context.set_code(grpc.StatusCode.UNIMPLEMENTED) context.set_details("Method not implemented!") @@ -125,6 +169,8 @@ def UpdateDatabaseDdl(self, request, context): def DropDatabase(self, request, context): """Drops (aka deletes) a Cloud Spanner database. + Completed backups for the database will be retained according to their + `expire_time`. """ context.set_code(grpc.StatusCode.UNIMPLEMENTED) context.set_details("Method not implemented!") @@ -140,35 +186,144 @@ def GetDatabaseDdl(self, request, context): raise NotImplementedError("Method not implemented!") def SetIamPolicy(self, request, context): - """Sets the access control policy on a database resource. + """Sets the access control policy on a database or backup resource. Replaces any existing policy. Authorization requires `spanner.databases.setIamPolicy` permission on [resource][google.iam.v1.SetIamPolicyRequest.resource]. + For backups, authorization requires `spanner.backups.setIamPolicy` + permission on [resource][google.iam.v1.SetIamPolicyRequest.resource]. """ context.set_code(grpc.StatusCode.UNIMPLEMENTED) context.set_details("Method not implemented!") raise NotImplementedError("Method not implemented!") def GetIamPolicy(self, request, context): - """Gets the access control policy for a database resource. - Returns an empty policy if a database exists but does - not have a policy set. + """Gets the access control policy for a database or backup resource. + Returns an empty policy if a database or backup exists but does not have a + policy set. Authorization requires `spanner.databases.getIamPolicy` permission on [resource][google.iam.v1.GetIamPolicyRequest.resource]. + For backups, authorization requires `spanner.backups.getIamPolicy` + permission on [resource][google.iam.v1.GetIamPolicyRequest.resource]. """ context.set_code(grpc.StatusCode.UNIMPLEMENTED) context.set_details("Method not implemented!") raise NotImplementedError("Method not implemented!") def TestIamPermissions(self, request, context): - """Returns permissions that the caller has on the specified database resource. + """Returns permissions that the caller has on the specified database or backup + resource. Attempting this RPC on a non-existent Cloud Spanner database will result in a NOT_FOUND error if the user has `spanner.databases.list` permission on the containing Cloud Spanner instance. Otherwise returns an empty set of permissions. + Calling this method on a backup that does not exist will + result in a NOT_FOUND error if the user has + `spanner.backups.list` permission on the containing instance. + """ + context.set_code(grpc.StatusCode.UNIMPLEMENTED) + context.set_details("Method not implemented!") + raise NotImplementedError("Method not implemented!") + + def CreateBackup(self, request, context): + """Starts creating a new Cloud Spanner Backup. + The returned backup [long-running operation][google.longrunning.Operation] + will have a name of the format + `projects//instances//backups//operations/` + and can be used to track creation of the backup. The + [metadata][google.longrunning.Operation.metadata] field type is + [CreateBackupMetadata][google.spanner.admin.database.v1.CreateBackupMetadata]. The + [response][google.longrunning.Operation.response] field type is + [Backup][google.spanner.admin.database.v1.Backup], if successful. Cancelling the returned operation will stop the + creation and delete the backup. + There can be only one pending backup creation per database. Backup creation + of different databases can run concurrently. + """ + context.set_code(grpc.StatusCode.UNIMPLEMENTED) + context.set_details("Method not implemented!") + raise NotImplementedError("Method not implemented!") + + def GetBackup(self, request, context): + """Gets metadata on a pending or completed [Backup][google.spanner.admin.database.v1.Backup]. + """ + context.set_code(grpc.StatusCode.UNIMPLEMENTED) + context.set_details("Method not implemented!") + raise NotImplementedError("Method not implemented!") + + def UpdateBackup(self, request, context): + """Updates a pending or completed [Backup][google.spanner.admin.database.v1.Backup]. + """ + context.set_code(grpc.StatusCode.UNIMPLEMENTED) + context.set_details("Method not implemented!") + raise NotImplementedError("Method not implemented!") + + def DeleteBackup(self, request, context): + """Deletes a pending or completed [Backup][google.spanner.admin.database.v1.Backup]. + """ + context.set_code(grpc.StatusCode.UNIMPLEMENTED) + context.set_details("Method not implemented!") + raise NotImplementedError("Method not implemented!") + + def ListBackups(self, request, context): + """Lists completed and pending backups. + Backups returned are ordered by `create_time` in descending order, + starting from the most recent `create_time`. + """ + context.set_code(grpc.StatusCode.UNIMPLEMENTED) + context.set_details("Method not implemented!") + raise NotImplementedError("Method not implemented!") + + def RestoreDatabase(self, request, context): + """Create a new database by restoring from a completed backup. The new + database must be in the same project and in an instance with the same + instance configuration as the instance containing + the backup. The returned database [long-running + operation][google.longrunning.Operation] has a name of the format + `projects//instances//databases//operations/`, + and can be used to track the progress of the operation, and to cancel it. + The [metadata][google.longrunning.Operation.metadata] field type is + [RestoreDatabaseMetadata][google.spanner.admin.database.v1.RestoreDatabaseMetadata]. + The [response][google.longrunning.Operation.response] type + is [Database][google.spanner.admin.database.v1.Database], if + successful. Cancelling the returned operation will stop the restore and + delete the database. + There can be only one database being restored into an instance at a time. + Once the restore operation completes, a new restore operation can be + initiated, without waiting for the optimize operation associated with the + first restore to complete. + """ + context.set_code(grpc.StatusCode.UNIMPLEMENTED) + context.set_details("Method not implemented!") + raise NotImplementedError("Method not implemented!") + + def ListDatabaseOperations(self, request, context): + """Lists database [longrunning-operations][google.longrunning.Operation]. + A database operation has a name of the form + `projects//instances//databases//operations/`. + The long-running operation + [metadata][google.longrunning.Operation.metadata] field type + `metadata.type_url` describes the type of the metadata. Operations returned + include those that have completed/failed/canceled within the last 7 days, + and pending operations. + """ + context.set_code(grpc.StatusCode.UNIMPLEMENTED) + context.set_details("Method not implemented!") + raise NotImplementedError("Method not implemented!") + + def ListBackupOperations(self, request, context): + """Lists the backup [long-running operations][google.longrunning.Operation] in + the given instance. A backup operation has a name of the form + `projects//instances//backups//operations/`. + The long-running operation + [metadata][google.longrunning.Operation.metadata] field type + `metadata.type_url` describes the type of the metadata. Operations returned + include those that have completed/failed/canceled within the last 7 days, + and pending operations. Operations returned are ordered by + `operation.metadata.value.progress.start_time` in descending order starting + from the most recently started operation. """ context.set_code(grpc.StatusCode.UNIMPLEMENTED) context.set_details("Method not implemented!") @@ -222,6 +377,46 @@ def add_DatabaseAdminServicer_to_server(servicer, server): request_deserializer=google_dot_iam_dot_v1_dot_iam__policy__pb2.TestIamPermissionsRequest.FromString, response_serializer=google_dot_iam_dot_v1_dot_iam__policy__pb2.TestIamPermissionsResponse.SerializeToString, ), + "CreateBackup": grpc.unary_unary_rpc_method_handler( + servicer.CreateBackup, + request_deserializer=google_dot_cloud_dot_spanner_dot_admin_dot_database__v1_dot_proto_dot_backup__pb2.CreateBackupRequest.FromString, + response_serializer=google_dot_longrunning_dot_operations__pb2.Operation.SerializeToString, + ), + "GetBackup": grpc.unary_unary_rpc_method_handler( + servicer.GetBackup, + request_deserializer=google_dot_cloud_dot_spanner_dot_admin_dot_database__v1_dot_proto_dot_backup__pb2.GetBackupRequest.FromString, + response_serializer=google_dot_cloud_dot_spanner_dot_admin_dot_database__v1_dot_proto_dot_backup__pb2.Backup.SerializeToString, + ), + "UpdateBackup": grpc.unary_unary_rpc_method_handler( + servicer.UpdateBackup, + request_deserializer=google_dot_cloud_dot_spanner_dot_admin_dot_database__v1_dot_proto_dot_backup__pb2.UpdateBackupRequest.FromString, + response_serializer=google_dot_cloud_dot_spanner_dot_admin_dot_database__v1_dot_proto_dot_backup__pb2.Backup.SerializeToString, + ), + "DeleteBackup": grpc.unary_unary_rpc_method_handler( + servicer.DeleteBackup, + request_deserializer=google_dot_cloud_dot_spanner_dot_admin_dot_database__v1_dot_proto_dot_backup__pb2.DeleteBackupRequest.FromString, + response_serializer=google_dot_protobuf_dot_empty__pb2.Empty.SerializeToString, + ), + "ListBackups": grpc.unary_unary_rpc_method_handler( + servicer.ListBackups, + request_deserializer=google_dot_cloud_dot_spanner_dot_admin_dot_database__v1_dot_proto_dot_backup__pb2.ListBackupsRequest.FromString, + response_serializer=google_dot_cloud_dot_spanner_dot_admin_dot_database__v1_dot_proto_dot_backup__pb2.ListBackupsResponse.SerializeToString, + ), + "RestoreDatabase": grpc.unary_unary_rpc_method_handler( + servicer.RestoreDatabase, + request_deserializer=google_dot_cloud_dot_spanner_dot_admin_dot_database__v1_dot_proto_dot_spanner__database__admin__pb2.RestoreDatabaseRequest.FromString, + response_serializer=google_dot_longrunning_dot_operations__pb2.Operation.SerializeToString, + ), + "ListDatabaseOperations": grpc.unary_unary_rpc_method_handler( + servicer.ListDatabaseOperations, + request_deserializer=google_dot_cloud_dot_spanner_dot_admin_dot_database__v1_dot_proto_dot_spanner__database__admin__pb2.ListDatabaseOperationsRequest.FromString, + response_serializer=google_dot_cloud_dot_spanner_dot_admin_dot_database__v1_dot_proto_dot_spanner__database__admin__pb2.ListDatabaseOperationsResponse.SerializeToString, + ), + "ListBackupOperations": grpc.unary_unary_rpc_method_handler( + servicer.ListBackupOperations, + request_deserializer=google_dot_cloud_dot_spanner_dot_admin_dot_database__v1_dot_proto_dot_backup__pb2.ListBackupOperationsRequest.FromString, + response_serializer=google_dot_cloud_dot_spanner_dot_admin_dot_database__v1_dot_proto_dot_backup__pb2.ListBackupOperationsResponse.SerializeToString, + ), } generic_handler = grpc.method_handlers_generic_handler( "google.spanner.admin.database.v1.DatabaseAdmin", rpc_method_handlers diff --git a/google/cloud/spanner_admin_instance_v1/gapic/instance_admin_client.py b/google/cloud/spanner_admin_instance_v1/gapic/instance_admin_client.py index c7c4912f2a..130a069bf5 100644 --- a/google/cloud/spanner_admin_instance_v1/gapic/instance_admin_client.py +++ b/google/cloud/spanner_admin_instance_v1/gapic/instance_admin_client.py @@ -562,8 +562,8 @@ def get_instance( Args: name (str): Required. The name of the requested instance. Values are of the form ``projects//instances/``. - field_mask (Union[dict, ~google.cloud.spanner_admin_instance_v1.types.FieldMask]): If field\_mask is present, specifies the subset of [][google.spanner.admin.instance.v1.Instance] fields - that should be returned. If absent, all [][google.spanner.admin.instance.v1.Instance] fields are + field_mask (Union[dict, ~google.cloud.spanner_admin_instance_v1.types.FieldMask]): If field\_mask is present, specifies the subset of ``Instance`` fields + that should be returned. If absent, all ``Instance`` fields are returned. If a dict is provided, it must be of the same form as the protobuf @@ -821,18 +821,15 @@ def update_instance( Args: instance (Union[dict, ~google.cloud.spanner_admin_instance_v1.types.Instance]): Required. The instance to update, which must always include the instance - name. Otherwise, only fields mentioned in - [][google.spanner.admin.instance.v1.UpdateInstanceRequest.field\_mask] - need be included. + name. Otherwise, only fields mentioned in ``field_mask`` need be + included. If a dict is provided, it must be of the same form as the protobuf message :class:`~google.cloud.spanner_admin_instance_v1.types.Instance` - field_mask (Union[dict, ~google.cloud.spanner_admin_instance_v1.types.FieldMask]): Required. A mask specifying which fields in - [][google.spanner.admin.instance.v1.UpdateInstanceRequest.instance] - should be updated. The field mask must always be specified; this - prevents any future fields in - [][google.spanner.admin.instance.v1.Instance] from being erased - accidentally by clients that do not know about them. + field_mask (Union[dict, ~google.cloud.spanner_admin_instance_v1.types.FieldMask]): Required. A mask specifying which fields in ``Instance`` should be + updated. The field mask must always be specified; this prevents any + future fields in ``Instance`` from being erased accidentally by clients + that do not know about them. If a dict is provided, it must be of the same form as the protobuf message :class:`~google.cloud.spanner_admin_instance_v1.types.FieldMask` diff --git a/google/cloud/spanner_admin_instance_v1/proto/spanner_instance_admin.proto b/google/cloud/spanner_admin_instance_v1/proto/spanner_instance_admin.proto index a437874133..6a068baca2 100644 --- a/google/cloud/spanner_admin_instance_v1/proto/spanner_instance_admin.proto +++ b/google/cloud/spanner_admin_instance_v1/proto/spanner_instance_admin.proto @@ -1,4 +1,4 @@ -// Copyright 2019 Google LLC. +// Copyright 2020 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -11,7 +11,6 @@ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. -// syntax = "proto3"; @@ -353,8 +352,8 @@ message Instance { // also [InstanceConfig][google.spanner.admin.instance.v1.InstanceConfig] and // [ListInstanceConfigs][google.spanner.admin.instance.v1.InstanceAdmin.ListInstanceConfigs]. string config = 2 [(google.api.resource_reference) = { - type: "spanner.googleapis.com/InstanceConfig" - }]; + type: "spanner.googleapis.com/InstanceConfig" + }]; // Required. The descriptive name for this instance as it appears in UIs. // Must be unique per project and between 4 and 30 characters in length. @@ -398,14 +397,7 @@ message Instance { // allow "_" in a future release. map labels = 7; - // Output only. The endpoint URIs based on the instance config. - // For example, instances located in a specific cloud region (or multi region) - // such as nam3, would have a nam3 specific endpoint URI. - // This URI is to be used implictly by SDK clients, with fallback to default - // URI. These endpoints are intended to optimize the network routing between - // the client and the instance's serving resources. - // If multiple endpoints are present, client may establish connections using - // any of the given URIs. + // Deprecated. This field is not populated. repeated string endpoint_uris = 8; } @@ -466,9 +458,9 @@ message GetInstanceRequest { } ]; - // If field_mask is present, specifies the subset of [][Instance] fields that + // If field_mask is present, specifies the subset of [Instance][google.spanner.admin.instance.v1.Instance] fields that // should be returned. - // If absent, all [][Instance] fields are returned. + // If absent, all [Instance][google.spanner.admin.instance.v1.Instance] fields are returned. google.protobuf.FieldMask field_mask = 2; } @@ -549,12 +541,12 @@ message ListInstancesResponse { // The request for [UpdateInstance][google.spanner.admin.instance.v1.InstanceAdmin.UpdateInstance]. message UpdateInstanceRequest { // Required. The instance to update, which must always include the instance - // name. Otherwise, only fields mentioned in [][google.spanner.admin.instance.v1.UpdateInstanceRequest.field_mask] need be included. + // name. Otherwise, only fields mentioned in [field_mask][google.spanner.admin.instance.v1.UpdateInstanceRequest.field_mask] need be included. Instance instance = 1 [(google.api.field_behavior) = REQUIRED]; - // Required. A mask specifying which fields in [][google.spanner.admin.instance.v1.UpdateInstanceRequest.instance] should be updated. + // Required. A mask specifying which fields in [Instance][google.spanner.admin.instance.v1.Instance] should be updated. // The field mask must always be specified; this prevents any future fields in - // [][google.spanner.admin.instance.v1.Instance] from being erased accidentally by clients that do not know + // [Instance][google.spanner.admin.instance.v1.Instance] from being erased accidentally by clients that do not know // about them. google.protobuf.FieldMask field_mask = 2 [(google.api.field_behavior) = REQUIRED]; } diff --git a/google/cloud/spanner_admin_instance_v1/proto/spanner_instance_admin_pb2.py b/google/cloud/spanner_admin_instance_v1/proto/spanner_instance_admin_pb2.py index 356c47f1a0..f00bfbbe0a 100644 --- a/google/cloud/spanner_admin_instance_v1/proto/spanner_instance_admin_pb2.py +++ b/google/cloud/spanner_admin_instance_v1/proto/spanner_instance_admin_pb2.py @@ -1398,15 +1398,7 @@ as the string: name + "*" + value would prove problematic if we were to allow "*" in a future release. endpoint_uris: - Output only. The endpoint URIs based on the instance config. - For example, instances located in a specific cloud region (or - multi region) such as nam3, would have a nam3 specific - endpoint URI. This URI is to be used implictly by SDK clients, - with fallback to default URI. These endpoints are intended to - optimize the network routing between the client and the - instance's serving resources. If multiple endpoints are - present, client may establish connections using any of the - given URIs. + Deprecated. This field is not populated. """, # @@protoc_insertion_point(class_scope:google.spanner.admin.instance.v1.Instance) ), @@ -1506,8 +1498,10 @@ the form ``projects//instances/``. field_mask: If field\_mask is present, specifies the subset of - [][Instance] fields that should be returned. If absent, all - [][Instance] fields are returned. + [Instance][google.spanner.admin.instance.v1.Instance] fields + that should be returned. If absent, all + [Instance][google.spanner.admin.instance.v1.Instance] fields + are returned. """, # @@protoc_insertion_point(class_scope:google.spanner.admin.instance.v1.GetInstanceRequest) ), @@ -1620,16 +1614,17 @@ Attributes: instance: Required. The instance to update, which must always include - the instance name. Otherwise, only fields mentioned in [][goog - le.spanner.admin.instance.v1.UpdateInstanceRequest.field\_mask - ] need be included. + the instance name. Otherwise, only fields mentioned in [field\ + _mask][google.spanner.admin.instance.v1.UpdateInstanceRequest. + field\_mask] need be included. field_mask: - Required. A mask specifying which fields in [][google.spanner. - admin.instance.v1.UpdateInstanceRequest.instance] should be - updated. The field mask must always be specified; this + Required. A mask specifying which fields in + [Instance][google.spanner.admin.instance.v1.Instance] should + be updated. The field mask must always be specified; this prevents any future fields in - [][google.spanner.admin.instance.v1.Instance] from being - erased accidentally by clients that do not know about them. + [Instance][google.spanner.admin.instance.v1.Instance] from + being erased accidentally by clients that do not know about + them. """, # @@protoc_insertion_point(class_scope:google.spanner.admin.instance.v1.UpdateInstanceRequest) ), diff --git a/google/cloud/spanner_v1/_helpers.py b/google/cloud/spanner_v1/_helpers.py index 3b7fd586c9..91e8c8d29c 100644 --- a/google/cloud/spanner_v1/_helpers.py +++ b/google/cloud/spanner_v1/_helpers.py @@ -26,6 +26,7 @@ from google.cloud._helpers import _date_from_iso8601_date from google.cloud._helpers import _datetime_to_rfc3339 from google.cloud.spanner_v1.proto import type_pb2 +from google.cloud.spanner_v1.proto.spanner_pb2 import ExecuteSqlRequest def _try_to_coerce_bytes(bytestring): @@ -47,6 +48,44 @@ def _try_to_coerce_bytes(bytestring): ) +def _merge_query_options(base, merge): + """Merge higher precedence QueryOptions with current QueryOptions. + + :type base: + :class:`google.cloud.spanner_v1.proto.ExecuteSqlRequest.QueryOptions` + or :class:`dict` or None + :param base: The current QueryOptions that is intended for use. + + :type merge: + :class:`google.cloud.spanner_v1.proto.ExecuteSqlRequest.QueryOptions` + or :class:`dict` or None + :param merge: + The QueryOptions that have a higher priority than base. These options + should overwrite the fields in base. + + :rtype: + :class:`google.cloud.spanner_v1.proto.ExecuteSqlRequest.QueryOptions` + or None + :returns: + QueryOptions object formed by merging the two given QueryOptions. + If the resultant object only has empty fields, returns None. + """ + combined = base or ExecuteSqlRequest.QueryOptions() + if type(combined) == dict: + combined = ExecuteSqlRequest.QueryOptions( + optimizer_version=combined.get("optimizer_version", "") + ) + merge = merge or ExecuteSqlRequest.QueryOptions() + if type(merge) == dict: + merge = ExecuteSqlRequest.QueryOptions( + optimizer_version=merge.get("optimizer_version", "") + ) + combined.MergeFrom(merge) + if not combined.optimizer_version: + return None + return combined + + # pylint: disable=too-many-return-statements,too-many-branches def _make_value_pb(value): """Helper for :func:`_make_list_value_pbs`. diff --git a/google/cloud/spanner_v1/backup.py b/google/cloud/spanner_v1/backup.py new file mode 100644 index 0000000000..2aaa1c0f5c --- /dev/null +++ b/google/cloud/spanner_v1/backup.py @@ -0,0 +1,275 @@ +# Copyright 2020 Google LLC All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# 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. + +"""User friendly container for Cloud Spanner Backup.""" + +import re + +from google.cloud._helpers import _datetime_to_pb_timestamp, _pb_timestamp_to_datetime +from google.cloud.exceptions import NotFound + +from google.cloud.spanner_admin_database_v1.gapic import enums +from google.cloud.spanner_v1._helpers import _metadata_with_prefix + +_BACKUP_NAME_RE = re.compile( + r"^projects/(?P[^/]+)/" + r"instances/(?P[a-z][-a-z0-9]*)/" + r"backups/(?P[a-z][a-z0-9_\-]*[a-z0-9])$" +) + + +class Backup(object): + """Representation of a Cloud Spanner Backup. + + We can use a :class`Backup` to: + + * :meth:`create` the backup + * :meth:`update` the backup + * :meth:`delete` the backup + + :type backup_id: str + :param backup_id: The ID of the backup. + + :type instance: :class:`~google.cloud.spanner_v1.instance.Instance` + :param instance: The instance that owns the backup. + + :type database: str + :param database: (Optional) The URI of the database that the backup is + for. Required if the create method needs to be called. + + :type expire_time: :class:`datetime.datetime` + :param expire_time: (Optional) The expire time that will be used to + create the backup. Required if the create method + needs to be called. + """ + + def __init__(self, backup_id, instance, database="", expire_time=None): + self.backup_id = backup_id + self._instance = instance + self._database = database + self._expire_time = expire_time + self._create_time = None + self._size_bytes = None + self._state = None + self._referencing_databases = None + + @property + def name(self): + """Backup name used in requests. + + The backup name is of the form + + ``"projects/../instances/../backups/{backup_id}"`` + + :rtype: str + :returns: The backup name. + """ + return self._instance.name + "/backups/" + self.backup_id + + @property + def database(self): + """Database name used in requests. + + The database name is of the form + + ``"projects/../instances/../backups/{backup_id}"`` + + :rtype: str + :returns: The database name. + """ + return self._database + + @property + def expire_time(self): + """Expire time used in creation requests. + + :rtype: :class:`datetime.datetime` + :returns: a datetime object representing the expire time of + this backup + """ + return self._expire_time + + @property + def create_time(self): + """Create time of this backup. + + :rtype: :class:`datetime.datetime` + :returns: a datetime object representing the create time of + this backup + """ + return self._create_time + + @property + def size_bytes(self): + """Size of this backup in bytes. + + :rtype: int + :returns: the number size of this backup measured in bytes + """ + return self._size_bytes + + @property + def state(self): + """State of this backup. + + :rtype: :class:`~google.cloud.spanner_admin_database_v1.gapic.enums.Backup.State` + :returns: an enum describing the state of the backup + """ + return self._state + + @property + def referencing_databases(self): + """List of databases referencing this backup. + + :rtype: list of strings + :returns: a list of database path strings which specify the databases still + referencing this backup + """ + return self._referencing_databases + + @classmethod + def from_pb(cls, backup_pb, instance): + """Create an instance of this class from a protobuf message. + + :type backup_pb: :class:`~google.spanner.admin.database.v1.Backup` + :param backup_pb: A backup protobuf object. + + :type instance: :class:`~google.cloud.spanner_v1.instance.Instance` + :param instance: The instance that owns the backup. + + :rtype: :class:`Backup` + :returns: The backup parsed from the protobuf response. + :raises ValueError: + if the backup name does not match the expected format or if + the parsed project ID does not match the project ID on the + instance's client, or if the parsed instance ID does not match + the instance's ID. + """ + match = _BACKUP_NAME_RE.match(backup_pb.name) + if match is None: + raise ValueError( + "Backup protobuf name was not in the expected format.", backup_pb.name + ) + if match.group("project") != instance._client.project: + raise ValueError( + "Project ID on backup does not match the project ID" + "on the instance's client" + ) + instance_id = match.group("instance_id") + if instance_id != instance.instance_id: + raise ValueError( + "Instance ID on database does not match the instance ID" + "on the instance" + ) + backup_id = match.group("backup_id") + return cls(backup_id, instance) + + def create(self): + """Create this backup within its instance. + + :rtype: :class:`~google.api_core.operation.Operation` + :returns: a future used to poll the status of the create request + :raises Conflict: if the backup already exists + :raises NotFound: if the instance owning the backup does not exist + :raises BadRequest: if the database or expire_time values are invalid + or expire_time is not set + """ + if not self._expire_time: + raise ValueError("expire_time not set") + if not self._database: + raise ValueError("database not set") + api = self._instance._client.database_admin_api + metadata = _metadata_with_prefix(self.name) + backup = { + "database": self._database, + "expire_time": _datetime_to_pb_timestamp(self.expire_time), + } + + future = api.create_backup( + self._instance.name, self.backup_id, backup, metadata=metadata + ) + return future + + def exists(self): + """Test whether this backup exists. + + :rtype: bool + :returns: True if the backup exists, else False. + """ + api = self._instance._client.database_admin_api + metadata = _metadata_with_prefix(self.name) + + try: + api.get_backup(self.name, metadata=metadata) + except NotFound: + return False + return True + + def reload(self): + """Reload this backup. + + Refresh the stored backup properties. + + :raises NotFound: if the backup does not exist + """ + api = self._instance._client.database_admin_api + metadata = _metadata_with_prefix(self.name) + pb = api.get_backup(self.name, metadata=metadata) + self._database = pb.database + self._expire_time = _pb_timestamp_to_datetime(pb.expire_time) + self._create_time = _pb_timestamp_to_datetime(pb.create_time) + self._size_bytes = pb.size_bytes + self._state = enums.Backup.State(pb.state) + self._referencing_databases = pb.referencing_databases + + def update_expire_time(self, new_expire_time): + """Update the expire time of this backup. + + :type new_expire_time: :class:`datetime.datetime` + :param new_expire_time: the new expire time timestamp + """ + api = self._instance._client.database_admin_api + metadata = _metadata_with_prefix(self.name) + backup_update = { + "name": self.name, + "expire_time": _datetime_to_pb_timestamp(new_expire_time), + } + update_mask = {"paths": ["expire_time"]} + api.update_backup(backup_update, update_mask, metadata=metadata) + self._expire_time = new_expire_time + + def is_ready(self): + """Test whether this backup is ready for use. + + :rtype: bool + :returns: True if the backup state is READY, else False. + """ + return self.state == enums.Backup.State.READY + + def delete(self): + """Delete this backup.""" + api = self._instance._client.database_admin_api + metadata = _metadata_with_prefix(self.name) + api.delete_backup(self.name, metadata=metadata) + + +class BackupInfo(object): + def __init__(self, backup, create_time, source_database): + self.backup = backup + self.create_time = _pb_timestamp_to_datetime(create_time) + self.source_database = source_database + + @classmethod + def from_pb(cls, pb): + return cls(pb.backup, pb.create_time, pb.source_database) diff --git a/google/cloud/spanner_v1/client.py b/google/cloud/spanner_v1/client.py index 264731178e..01b3ddfabf 100644 --- a/google/cloud/spanner_v1/client.py +++ b/google/cloud/spanner_v1/client.py @@ -23,11 +23,21 @@ * a :class:`~google.cloud.spanner_v1.instance.Instance` owns a :class:`~google.cloud.spanner_v1.database.Database` """ +import grpc +import os import warnings from google.api_core.gapic_v1 import client_info import google.api_core.client_options +from google.cloud.spanner_admin_instance_v1.gapic.transports import ( + instance_admin_grpc_transport, +) + +from google.cloud.spanner_admin_database_v1.gapic.transports import ( + database_admin_grpc_transport, +) + # pylint: disable=line-too-long from google.cloud.spanner_admin_database_v1.gapic.database_admin_client import ( # noqa DatabaseAdminClient, @@ -40,18 +50,34 @@ from google.cloud.client import ClientWithProject from google.cloud.spanner_v1 import __version__ -from google.cloud.spanner_v1._helpers import _metadata_with_prefix +from google.cloud.spanner_v1._helpers import _merge_query_options, _metadata_with_prefix from google.cloud.spanner_v1.instance import DEFAULT_NODE_COUNT from google.cloud.spanner_v1.instance import Instance +from google.cloud.spanner_v1.proto.spanner_pb2 import ExecuteSqlRequest _CLIENT_INFO = client_info.ClientInfo(client_library_version=__version__) +EMULATOR_ENV_VAR = "SPANNER_EMULATOR_HOST" +_EMULATOR_HOST_HTTP_SCHEME = ( + "%s contains a http scheme. When used with a scheme it may cause gRPC's " + "DNS resolver to endlessly attempt to resolve. %s is intended to be used " + "without a scheme: ex %s=localhost:8080." +) % ((EMULATOR_ENV_VAR,) * 3) SPANNER_ADMIN_SCOPE = "https://www.googleapis.com/auth/spanner.admin" +OPTIMIZER_VERSION_ENV_VAR = "SPANNER_OPTIMIZER_VERSION" _USER_AGENT_DEPRECATED = ( "The 'user_agent' argument to 'Client' is deprecated / unused. " "Please pass an appropriate 'client_info' instead." ) +def _get_spanner_emulator_host(): + return os.getenv(EMULATOR_ENV_VAR) + + +def _get_spanner_optimizer_version(): + return os.getenv(OPTIMIZER_VERSION_ENV_VAR, "") + + class InstanceConfig(object): """Named configurations for Spanner instances. @@ -112,11 +138,20 @@ class Client(ClientWithProject): :param user_agent: (Deprecated) The user agent to be used with API request. Not used. + :type client_options: :class:`~google.api_core.client_options.ClientOptions` or :class:`dict` :param client_options: (Optional) Client options used to set user options on the client. API Endpoint should be set through client_options. + :type query_options: + :class:`google.cloud.spanner_v1.proto.ExecuteSqlRequest.QueryOptions` + or :class:`dict` + :param query_options: + (Optional) Query optimizer configuration to use for the given query. + If a dict is provided, it must be of the same form as the protobuf + message :class:`~google.cloud.spanner_v1.types.QueryOptions` + :raises: :class:`ValueError ` if both ``read_only`` and ``admin`` are :data:`True` """ @@ -137,6 +172,7 @@ def __init__( client_info=_CLIENT_INFO, user_agent=None, client_options=None, + query_options=None, ): # NOTE: This API has no use for the _http argument, but sending it # will have no impact since the _http() @property only lazily @@ -152,10 +188,23 @@ def __init__( else: self._client_options = client_options + env_query_options = ExecuteSqlRequest.QueryOptions( + optimizer_version=_get_spanner_optimizer_version() + ) + + # Environment flag config has higher precedence than application config. + self._query_options = _merge_query_options(query_options, env_query_options) + if user_agent is not None: warnings.warn(_USER_AGENT_DEPRECATED, DeprecationWarning, stacklevel=2) self.user_agent = user_agent + if _get_spanner_emulator_host() is not None and ( + "http://" in _get_spanner_emulator_host() + or "https://" in _get_spanner_emulator_host() + ): + warnings.warn(_EMULATOR_HOST_HTTP_SCHEME) + @property def credentials(self): """Getter for client's credentials. @@ -189,22 +238,42 @@ def project_name(self): def instance_admin_api(self): """Helper for session-related API calls.""" if self._instance_admin_api is None: - self._instance_admin_api = InstanceAdminClient( - credentials=self.credentials, - client_info=self._client_info, - client_options=self._client_options, - ) + if _get_spanner_emulator_host() is not None: + transport = instance_admin_grpc_transport.InstanceAdminGrpcTransport( + channel=grpc.insecure_channel(_get_spanner_emulator_host()) + ) + self._instance_admin_api = InstanceAdminClient( + client_info=self._client_info, + client_options=self._client_options, + transport=transport, + ) + else: + self._instance_admin_api = InstanceAdminClient( + credentials=self.credentials, + client_info=self._client_info, + client_options=self._client_options, + ) return self._instance_admin_api @property def database_admin_api(self): """Helper for session-related API calls.""" if self._database_admin_api is None: - self._database_admin_api = DatabaseAdminClient( - credentials=self.credentials, - client_info=self._client_info, - client_options=self._client_options, - ) + if _get_spanner_emulator_host() is not None: + transport = database_admin_grpc_transport.DatabaseAdminGrpcTransport( + channel=grpc.insecure_channel(_get_spanner_emulator_host()) + ) + self._database_admin_api = DatabaseAdminClient( + client_info=self._client_info, + client_options=self._client_options, + transport=transport, + ) + else: + self._database_admin_api = DatabaseAdminClient( + credentials=self.credentials, + client_info=self._client_info, + client_options=self._client_options, + ) return self._database_admin_api def copy(self): @@ -288,7 +357,14 @@ def instance( :rtype: :class:`~google.cloud.spanner_v1.instance.Instance` :returns: an instance owned by this client. """ - return Instance(instance_id, self, configuration_name, node_count, display_name) + return Instance( + instance_id, + self, + configuration_name, + node_count, + display_name, + _get_spanner_emulator_host(), + ) def list_instances(self, filter_="", page_size=None, page_token=None): """List instances for the client's project. diff --git a/google/cloud/spanner_v1/database.py b/google/cloud/spanner_v1/database.py index 49abe919d5..5785953bd7 100644 --- a/google/cloud/spanner_v1/database.py +++ b/google/cloud/spanner_v1/database.py @@ -16,6 +16,7 @@ import copy import functools +import grpc import os import re import threading @@ -29,10 +30,16 @@ import six # pylint: disable=ungrouped-imports -from google.cloud.spanner_v1._helpers import _make_value_pb -from google.cloud.spanner_v1._helpers import _metadata_with_prefix +from google.cloud.spanner_admin_database_v1.gapic import enums +from google.cloud.spanner_v1._helpers import ( + _make_value_pb, + _merge_query_options, + _metadata_with_prefix, +) +from google.cloud.spanner_v1.backup import BackupInfo from google.cloud.spanner_v1.batch import Batch from google.cloud.spanner_v1.gapic.spanner_client import SpannerClient +from google.cloud.spanner_v1.gapic.transports import spanner_grpc_transport from google.cloud.spanner_v1.keyset import KeySet from google.cloud.spanner_v1.pool import BurstyPool from google.cloud.spanner_v1.pool import SessionCheckout @@ -44,6 +51,7 @@ TransactionSelector, TransactionOptions, ) +from google.cloud._helpers import _pb_timestamp_to_datetime # pylint: enable=ungrouped-imports @@ -57,6 +65,7 @@ r"databases/(?P[a-z][a-z0-9_\-]*[a-z0-9])$" ) +_DATABASE_METADATA_FILTER = "name:{0}/operations/" _RESOURCE_ROUTING_PERMISSIONS_WARNING = ( "The client library attempted to connect to an endpoint closer to your Cloud Spanner data " @@ -105,6 +114,9 @@ def __init__(self, database_id, instance, ddl_statements=(), pool=None): self._instance = instance self._ddl_statements = _check_ddl_statements(ddl_statements) self._local = threading.local() + self._state = None + self._create_time = None + self._restore_info = None if pool is None: pool = BurstyPool() @@ -174,6 +186,34 @@ def name(self): """ return self._instance.name + "/databases/" + self.database_id + @property + def state(self): + """State of this database. + + :rtype: :class:`~google.cloud.spanner_admin_database_v1.gapic.enums.Database.State` + :returns: an enum describing the state of the database + """ + return self._state + + @property + def create_time(self): + """Create time of this database. + + :rtype: :class:`datetime.datetime` + :returns: a datetime object representing the create time of + this database + """ + return self._create_time + + @property + def restore_info(self): + """Restore info for this database. + + :rtype: :class:`~google.cloud.spanner_v1.database.RestoreInfo` + :returns: an object representing the restore info for this database + """ + return self._restore_info + @property def ddl_statements(self): """DDL Statements used to define database schema. @@ -190,11 +230,21 @@ def ddl_statements(self): def spanner_api(self): """Helper for session-related API calls.""" if self._spanner_api is None: + client_info = self._instance._client._client_info + client_options = self._instance._client._client_options + if self._instance.emulator_host is not None: + transport = spanner_grpc_transport.SpannerGrpcTransport( + channel=grpc.insecure_channel(self._instance.emulator_host) + ) + self._spanner_api = SpannerClient( + client_info=client_info, + client_options=client_options, + transport=transport, + ) + return self._spanner_api credentials = self._instance._client.credentials if isinstance(credentials, google.auth.credentials.Scoped): credentials = credentials.with_scopes((SPANNER_DATA_SCOPE,)) - client_info = self._instance._client._client_info - client_options = self._instance._client._client_options if ( os.getenv("GOOGLE_CLOUD_SPANNER_ENABLE_RESOURCE_BASED_ROUTING") == "true" @@ -301,6 +351,10 @@ def reload(self): metadata = _metadata_with_prefix(self.name) response = api.get_database_ddl(self.name, metadata=metadata) self._ddl_statements = tuple(response.statements) + response = api.get_database(self.name, metadata=metadata) + self._state = enums.Database.State(response.state) + self._create_time = _pb_timestamp_to_datetime(response.create_time) + self._restore_info = response.restore_info def update_ddl(self, ddl_statements, operation_id=""): """Update DDL for this database. @@ -338,7 +392,9 @@ def drop(self): metadata = _metadata_with_prefix(self.name) api.drop_database(self.name, metadata=metadata) - def execute_partitioned_dml(self, dml, params=None, param_types=None): + def execute_partitioned_dml( + self, dml, params=None, param_types=None, query_options=None + ): """Execute a partitionable DML statement. :type dml: str @@ -353,9 +409,20 @@ def execute_partitioned_dml(self, dml, params=None, param_types=None): (Optional) maps explicit types for one or more param values; required if parameters are passed. + :type query_options: + :class:`google.cloud.spanner_v1.proto.ExecuteSqlRequest.QueryOptions` + or :class:`dict` + :param query_options: + (Optional) Query optimizer configuration to use for the given query. + If a dict is provided, it must be of the same form as the protobuf + message :class:`~google.cloud.spanner_v1.types.QueryOptions` + :rtype: int :returns: Count of rows affected by the DML statement. """ + query_options = _merge_query_options( + self._instance._client._query_options, query_options + ) if params is not None: if param_types is None: raise ValueError("Specify 'param_types' when passing 'params'.") @@ -386,6 +453,7 @@ def execute_partitioned_dml(self, dml, params=None, param_types=None): transaction=txn_selector, params=params_pb, param_types=param_types, + query_options=query_options, metadata=metadata, ) @@ -492,6 +560,73 @@ def run_in_transaction(self, func, *args, **kw): finally: self._local.transaction_running = False + def restore(self, source): + """Restore from a backup to this database. + + :type backup: :class:`~google.cloud.spanner_v1.backup.Backup` + :param backup: the path of the backup being restored from. + + :rtype: :class:'~google.api_core.operation.Operation` + :returns: a future used to poll the status of the create request + :raises Conflict: if the database already exists + :raises NotFound: + if the instance owning the database does not exist, or + if the backup being restored from does not exist + :raises ValueError: if backup is not set + """ + if source is None: + raise ValueError("Restore source not specified") + api = self._instance._client.database_admin_api + metadata = _metadata_with_prefix(self.name) + future = api.restore_database( + self._instance.name, self.database_id, backup=source.name, metadata=metadata + ) + return future + + def is_ready(self): + """Test whether this database is ready for use. + + :rtype: bool + :returns: True if the database state is READY_OPTIMIZING or READY, else False. + """ + return ( + self.state == enums.Database.State.READY_OPTIMIZING + or self.state == enums.Database.State.READY + ) + + def is_optimized(self): + """Test whether this database has finished optimizing. + + :rtype: bool + :returns: True if the database state is READY, else False. + """ + return self.state == enums.Database.State.READY + + def list_database_operations(self, filter_="", page_size=None): + """List database operations for the database. + + :type filter_: str + :param filter_: + Optional. A string specifying a filter for which database operations to list. + + :type page_size: int + :param page_size: + Optional. The maximum number of operations in each page of results from this + request. Non-positive values are ignored. Defaults to a sensible value set + by the API. + + :type: :class:`~google.api_core.page_iterator.Iterator` + :returns: + Iterator of :class:`~google.api_core.operation.Operation` + resources within the current instance. + """ + database_filter = _DATABASE_METADATA_FILTER.format(self.name) + if filter_: + database_filter = "({0}) AND ({1})".format(filter_, database_filter) + return self._instance.list_database_operations( + filter_=database_filter, page_size=page_size + ) + class BatchCheckout(object): """Context manager for using a batch from a database. @@ -736,6 +871,7 @@ def generate_query_batches( param_types=None, partition_size_bytes=None, max_partitions=None, + query_options=None, ): """Start a partitioned query operation. @@ -771,6 +907,14 @@ def generate_query_batches( service uses this as a hint, the actual number of partitions may differ. + :type query_options: + :class:`google.cloud.spanner_v1.proto.ExecuteSqlRequest.QueryOptions` + or :class:`dict` + :param query_options: + (Optional) Query optimizer configuration to use for the given query. + If a dict is provided, it must be of the same form as the protobuf + message :class:`~google.cloud.spanner_v1.types.QueryOptions` + :rtype: iterable of dict :returns: mappings of information used peform actual partitioned reads via @@ -789,6 +933,13 @@ def generate_query_batches( query_info["params"] = params query_info["param_types"] = param_types + # Query-level options have higher precedence than client-level and + # environment-level options + default_query_options = self._database._instance._client._query_options + query_info["query_options"] = _merge_query_options( + default_query_options, query_options + ) + for partition in partitions: yield {"partition": partition, "query": query_info} @@ -861,3 +1012,13 @@ def _check_ddl_statements(value): raise ValueError("Do not pass a 'CREATE DATABASE' statement") return tuple(value) + + +class RestoreInfo(object): + def __init__(self, source_type, backup_info): + self.source_type = enums.RestoreSourceType(source_type) + self.backup_info = BackupInfo.from_pb(backup_info) + + @classmethod + def from_pb(cls, pb): + return cls(pb.source_type, pb.backup_info) diff --git a/google/cloud/spanner_v1/gapic/spanner_client.py b/google/cloud/spanner_v1/gapic/spanner_client.py index cf6aafd6b6..20b6522780 100644 --- a/google/cloud/spanner_v1/gapic/spanner_client.py +++ b/google/cloud/spanner_v1/gapic/spanner_client.py @@ -237,7 +237,7 @@ def create_session( Active sessions use additional server resources, so it is a good idea to delete idle and unneeded sessions. Aside from explicit deletes, Cloud - Spanner can delete sessions for which no operations are sent for more + Spanner may delete sessions for which no operations are sent for more than an hour. If a session is deleted, requests to it return ``NOT_FOUND``. @@ -659,6 +659,7 @@ def execute_sql( query_mode=None, partition_token=None, seqno=None, + query_options=None, retry=google.api_core.gapic_v1.method.DEFAULT, timeout=google.api_core.gapic_v1.method.DEFAULT, metadata=None, @@ -752,6 +753,10 @@ def execute_sql( handled requests will yield the same response as the first execution. Required for DML statements. Ignored for queries. + query_options (Union[dict, ~google.cloud.spanner_v1.types.QueryOptions]): Query optimizer configuration to use for the given query. + + If a dict is provided, it must be of the same form as the protobuf + message :class:`~google.cloud.spanner_v1.types.QueryOptions` retry (Optional[google.api_core.retry.Retry]): A retry object used to retry requests. If ``None`` is specified, requests will be retried using a default configuration. @@ -792,6 +797,7 @@ def execute_sql( query_mode=query_mode, partition_token=partition_token, seqno=seqno, + query_options=query_options, ) if metadata is None: metadata = [] @@ -821,6 +827,7 @@ def execute_streaming_sql( query_mode=None, partition_token=None, seqno=None, + query_options=None, retry=google.api_core.gapic_v1.method.DEFAULT, timeout=google.api_core.gapic_v1.method.DEFAULT, metadata=None, @@ -909,6 +916,10 @@ def execute_streaming_sql( handled requests will yield the same response as the first execution. Required for DML statements. Ignored for queries. + query_options (Union[dict, ~google.cloud.spanner_v1.types.QueryOptions]): Query optimizer configuration to use for the given query. + + If a dict is provided, it must be of the same form as the protobuf + message :class:`~google.cloud.spanner_v1.types.QueryOptions` retry (Optional[google.api_core.retry.Retry]): A retry object used to retry requests. If ``None`` is specified, requests will be retried using a default configuration. @@ -949,6 +960,7 @@ def execute_streaming_sql( query_mode=query_mode, partition_token=partition_token, seqno=seqno, + query_options=query_options, ) if metadata is None: metadata = [] @@ -1028,9 +1040,9 @@ def execute_batch_dml( If a dict is provided, it must be of the same form as the protobuf message :class:`~google.cloud.spanner_v1.types.Statement` - seqno (long): Required. A per-transaction sequence number used to identify this request. - This field makes each request idempotent such that if the request is - received multiple times, at most one will succeed. + seqno (long): Required. A per-transaction sequence number used to identify this request. This field + 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 diff --git a/google/cloud/spanner_v1/gapic/transports/spanner_grpc_transport.py b/google/cloud/spanner_v1/gapic/transports/spanner_grpc_transport.py index 47cedd3cc8..3d43f5088e 100644 --- a/google/cloud/spanner_v1/gapic/transports/spanner_grpc_transport.py +++ b/google/cloud/spanner_v1/gapic/transports/spanner_grpc_transport.py @@ -133,7 +133,7 @@ def create_session(self): Active sessions use additional server resources, so it is a good idea to delete idle and unneeded sessions. Aside from explicit deletes, Cloud - Spanner can delete sessions for which no operations are sent for more + Spanner may delete sessions for which no operations are sent for more than an hour. If a session is deleted, requests to it return ``NOT_FOUND``. diff --git a/google/cloud/spanner_v1/instance.py b/google/cloud/spanner_v1/instance.py index 83a600bd10..4a14032c13 100644 --- a/google/cloud/spanner_v1/instance.py +++ b/google/cloud/spanner_v1/instance.py @@ -14,16 +14,23 @@ """User friendly container for Cloud Spanner Instance.""" +import google.api_core.operation import re from google.cloud.spanner_admin_instance_v1.proto import ( spanner_instance_admin_pb2 as admin_v1_pb2, ) +from google.cloud.spanner_admin_database_v1.proto import ( + backup_pb2, + spanner_database_admin_pb2, +) +from google.protobuf.empty_pb2 import Empty from google.protobuf.field_mask_pb2 import FieldMask # pylint: disable=ungrouped-imports from google.cloud.exceptions import NotFound from google.cloud.spanner_v1._helpers import _metadata_with_prefix +from google.cloud.spanner_v1.backup import Backup from google.cloud.spanner_v1.database import Database from google.cloud.spanner_v1.pool import BurstyPool @@ -36,6 +43,33 @@ DEFAULT_NODE_COUNT = 1 +_OPERATION_METADATA_MESSAGES = ( + backup_pb2.Backup, + backup_pb2.CreateBackupMetadata, + spanner_database_admin_pb2.CreateDatabaseMetadata, + spanner_database_admin_pb2.Database, + spanner_database_admin_pb2.OptimizeRestoredDatabaseMetadata, + spanner_database_admin_pb2.RestoreDatabaseMetadata, + spanner_database_admin_pb2.UpdateDatabaseDdlMetadata, +) + +_OPERATION_METADATA_TYPES = { + "type.googleapis.com/{}".format(message.DESCRIPTOR.full_name): message + for message in _OPERATION_METADATA_MESSAGES +} + +_OPERATION_RESPONSE_TYPES = { + backup_pb2.CreateBackupMetadata: backup_pb2.Backup, + spanner_database_admin_pb2.CreateDatabaseMetadata: spanner_database_admin_pb2.Database, + spanner_database_admin_pb2.OptimizeRestoredDatabaseMetadata: spanner_database_admin_pb2.Database, + spanner_database_admin_pb2.RestoreDatabaseMetadata: spanner_database_admin_pb2.Database, + spanner_database_admin_pb2.UpdateDatabaseDdlMetadata: Empty, +} + + +def _type_string_to_type_pb(type_string): + return _OPERATION_METADATA_TYPES.get(type_string, Empty) + class Instance(object): """Representation of a Cloud Spanner Instance. @@ -76,12 +110,14 @@ def __init__( configuration_name=None, node_count=DEFAULT_NODE_COUNT, display_name=None, + emulator_host=None, ): self.instance_id = instance_id self._client = client self.configuration_name = configuration_name self.node_count = node_count self.display_name = display_name or instance_id + self.emulator_host = emulator_host def _update_from_pb(self, instance_pb): """Refresh self from the server-provided protobuf. @@ -377,3 +413,136 @@ def _item_to_database(self, iterator, database_pb): :returns: The next database in the page. """ return Database.from_pb(database_pb, self, pool=BurstyPool()) + + def backup(self, backup_id, database="", expire_time=None): + """Factory to create a backup within this instance. + + :type backup_id: str + :param backup_id: The ID of the backup. + + :type database: :class:`~google.cloud.spanner_v1.database.Database` + :param database: + Optional. The database that will be used when creating the backup. + Required if the create method needs to be called. + + :type expire_time: :class:`datetime.datetime` + :param expire_time: + Optional. The expire time that will be used when creating the backup. + Required if the create method needs to be called. + """ + try: + return Backup( + backup_id, self, database=database.name, expire_time=expire_time + ) + except AttributeError: + return Backup(backup_id, self, database=database, expire_time=expire_time) + + def list_backups(self, filter_="", page_size=None): + """List backups for the instance. + + :type filter_: str + :param filter_: + Optional. A string specifying a filter for which backups to list. + + :type page_size: int + :param page_size: + Optional. The maximum number of databases in each page of results + from this request. Non-positive values are ignored. Defaults to a + sensible value set by the API. + + :rtype: :class:`~google.api_core.page_iterator.Iterator` + :returns: + Iterator of :class:`~google.cloud.spanner_v1.backup.Backup` + resources within the current instance. + """ + metadata = _metadata_with_prefix(self.name) + page_iter = self._client.database_admin_api.list_backups( + self.name, filter_, page_size=page_size, metadata=metadata + ) + page_iter.item_to_value = self._item_to_backup + return page_iter + + def _item_to_backup(self, iterator, backup_pb): + """Convert a backup protobuf to the native object. + + :type iterator: :class:`~google.api_core.page_iterator.Iterator` + :param iterator: The iterator that is currently in use. + + :type backup_pb: :class:`~google.spanner.admin.database.v1.Backup` + :param backup_pb: A backup returned from the API. + + :rtype: :class:`~google.cloud.spanner_v1.backup.Backup` + :returns: The next backup in the page. + """ + return Backup.from_pb(backup_pb, self) + + def list_backup_operations(self, filter_="", page_size=None): + """List backup operations for the instance. + + :type filter_: str + :param filter_: + Optional. A string specifying a filter for which backup operations + to list. + + :type page_size: int + :param page_size: + Optional. The maximum number of operations in each page of results + from this request. Non-positive values are ignored. Defaults to a + sensible value set by the API. + + :rtype: :class:`~google.api_core.page_iterator.Iterator` + :returns: + Iterator of :class:`~google.api_core.operation.Operation` + resources within the current instance. + """ + metadata = _metadata_with_prefix(self.name) + page_iter = self._client.database_admin_api.list_backup_operations( + self.name, filter_, page_size=page_size, metadata=metadata + ) + page_iter.item_to_value = self._item_to_operation + return page_iter + + def list_database_operations(self, filter_="", page_size=None): + """List database operations for the instance. + + :type filter_: str + :param filter_: + Optional. A string specifying a filter for which database operations + to list. + + :type page_size: int + :param page_size: + Optional. The maximum number of operations in each page of results + from this request. Non-positive values are ignored. Defaults to a + sensible value set by the API. + + :rtype: :class:`~google.api_core.page_iterator.Iterator` + :returns: + Iterator of :class:`~google.api_core.operation.Operation` + resources within the current instance. + """ + metadata = _metadata_with_prefix(self.name) + page_iter = self._client.database_admin_api.list_database_operations( + self.name, filter_, page_size=page_size, metadata=metadata + ) + page_iter.item_to_value = self._item_to_operation + return page_iter + + def _item_to_operation(self, iterator, operation_pb): + """Convert an operation protobuf to the native object. + + :type iterator: :class:`~google.api_core.page_iterator.Iterator` + :param iterator: The iterator that is currently in use. + + :type operation_pb: :class:`~google.longrunning.operations.Operation` + :param operation_pb: An operation returned from the API. + + :rtype: :class:`~google.api_core.operation.Operation` + :returns: The next operation in the page. + """ + operations_client = self._client.database_admin_api.transport._operations_client + metadata_type = _type_string_to_type_pb(operation_pb.metadata.type_url) + response_type = _OPERATION_RESPONSE_TYPES[metadata_type] + return google.api_core.operation.from_gapic( + operation_pb, operations_client, response_type, metadata_type=metadata_type + ) diff --git a/google/cloud/spanner_v1/pool.py b/google/cloud/spanner_v1/pool.py index ce7a196b6b..cf3413ceb1 100644 --- a/google/cloud/spanner_v1/pool.py +++ b/google/cloud/spanner_v1/pool.py @@ -171,10 +171,7 @@ def bind(self, database): while not self._sessions.full(): resp = api.batch_create_sessions( - database.name, - self.size - self._sessions.qsize(), - timeout=self.default_timeout, - metadata=metadata, + database.name, self.size - self._sessions.qsize(), metadata=metadata ) for session_pb in resp.session: session = self._new_session() @@ -365,10 +362,7 @@ def bind(self, database): while created_session_count < self.size: resp = api.batch_create_sessions( - database.name, - self.size - created_session_count, - timeout=self.default_timeout, - metadata=metadata, + database.name, self.size - created_session_count, metadata=metadata ) for session_pb in resp.session: session = self._new_session() @@ -503,7 +497,7 @@ def put(self, session): raise queue.Full txn = session._transaction - if txn is None or txn.committed or txn._rolled_back: + if txn is None or txn.committed or txn.rolled_back: session.transaction() self._pending_sessions.put(session) else: diff --git a/google/cloud/spanner_v1/proto/keys.proto b/google/cloud/spanner_v1/proto/keys.proto index de5307aaaf..d129255c45 100644 --- a/google/cloud/spanner_v1/proto/keys.proto +++ b/google/cloud/spanner_v1/proto/keys.proto @@ -1,4 +1,4 @@ -// Copyright 2019 Google LLC. +// Copyright 2020 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -11,7 +11,6 @@ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. -// syntax = "proto3"; diff --git a/google/cloud/spanner_v1/proto/mutation.proto b/google/cloud/spanner_v1/proto/mutation.proto index 7df99c0ee6..2c675830f0 100644 --- a/google/cloud/spanner_v1/proto/mutation.proto +++ b/google/cloud/spanner_v1/proto/mutation.proto @@ -1,4 +1,4 @@ -// Copyright 2019 Google LLC. +// Copyright 2020 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -11,7 +11,6 @@ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. -// syntax = "proto3"; @@ -61,7 +60,10 @@ message Mutation { // Required. The table whose rows will be deleted. string table = 1; - // Required. The primary keys of the rows within [table][google.spanner.v1.Mutation.Delete.table] to delete. + // Required. The primary keys of the rows within [table][google.spanner.v1.Mutation.Delete.table] to delete. The + // primary keys must be specified in the order in which they appear in the + // `PRIMARY KEY()` clause of the table's equivalent DDL statement (the DDL + // statement used to create the table). // Delete is idempotent. The transaction will succeed even if some or all // rows do not exist. KeySet key_set = 2; @@ -80,6 +82,10 @@ message Mutation { // Like [insert][google.spanner.v1.Mutation.insert], except that if the row already exists, then // its column values are overwritten with the ones provided. Any // column values not explicitly written are preserved. + // + // When using [insert_or_update][google.spanner.v1.Mutation.insert_or_update], just as when using [insert][google.spanner.v1.Mutation.insert], all `NOT + // NULL` columns in the table must be given a value. This holds true + // even when the row already exists and will therefore actually be updated. Write insert_or_update = 3; // Like [insert][google.spanner.v1.Mutation.insert], except that if the row already exists, it is diff --git a/google/cloud/spanner_v1/proto/mutation_pb2.py b/google/cloud/spanner_v1/proto/mutation_pb2.py index db5a781f69..b6ad0429b8 100644 --- a/google/cloud/spanner_v1/proto/mutation_pb2.py +++ b/google/cloud/spanner_v1/proto/mutation_pb2.py @@ -383,8 +383,11 @@ 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. + The primary keys must be specified in the order in which they + appear in the ``PRIMARY KEY()`` clause of the table's + equivalent DDL statement (the DDL statement used to create the + table). 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) ), @@ -409,7 +412,12 @@ Like [insert][google.spanner.v1.Mutation.insert], except that if the row already exists, then its column values are overwritten with the ones provided. Any column values not - explicitly written are preserved. + explicitly written are preserved. When using [insert\_or\_upd + ate][google.spanner.v1.Mutation.insert\_or\_update], just as + when using [insert][google.spanner.v1.Mutation.insert], all + ``NOT NULL`` columns in the table must be given a value. This + holds true even when the row already exists and will therefore + actually be updated. replace: Like [insert][google.spanner.v1.Mutation.insert], except that if the row already exists, it is deleted, and the column diff --git a/google/cloud/spanner_v1/proto/query_plan.proto b/google/cloud/spanner_v1/proto/query_plan.proto index 2d6be2e2bd..6ad13a77b0 100644 --- a/google/cloud/spanner_v1/proto/query_plan.proto +++ b/google/cloud/spanner_v1/proto/query_plan.proto @@ -1,4 +1,4 @@ -// Copyright 2019 Google LLC. +// Copyright 2020 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -11,7 +11,6 @@ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. -// syntax = "proto3"; diff --git a/google/cloud/spanner_v1/proto/query_plan_pb2.py b/google/cloud/spanner_v1/proto/query_plan_pb2.py index bc715b4549..4602cd6b15 100644 --- a/google/cloud/spanner_v1/proto/query_plan_pb2.py +++ b/google/cloud/spanner_v1/proto/query_plan_pb2.py @@ -511,8 +511,8 @@ ), DESCRIPTOR=_PLANNODE_SHORTREPRESENTATION, __module__="google.cloud.spanner_v1.proto.query_plan_pb2", - __doc__="""Condensed representation of a node and its subtree. Only present for - ``SCALAR`` [PlanNode(s)][google.spanner.v1.PlanNode]. + __doc__="""Condensed representation of a node and its subtree. Only + present for ``SCALAR`` [PlanNode(s)][google.spanner.v1.PlanNode]. Attributes: diff --git a/google/cloud/spanner_v1/proto/result_set.proto b/google/cloud/spanner_v1/proto/result_set.proto index a4b785283c..e24a35aaf8 100644 --- a/google/cloud/spanner_v1/proto/result_set.proto +++ b/google/cloud/spanner_v1/proto/result_set.proto @@ -1,4 +1,4 @@ -// Copyright 2019 Google LLC. +// Copyright 2020 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -11,7 +11,6 @@ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. -// syntax = "proto3"; diff --git a/google/cloud/spanner_v1/proto/spanner.proto b/google/cloud/spanner_v1/proto/spanner.proto index 2ff4c8db89..0c7da37c72 100644 --- a/google/cloud/spanner_v1/proto/spanner.proto +++ b/google/cloud/spanner_v1/proto/spanner.proto @@ -1,4 +1,4 @@ -// Copyright 2019 Google LLC. +// Copyright 2020 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -11,7 +11,6 @@ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. -// syntax = "proto3"; @@ -37,10 +36,6 @@ option java_multiple_files = true; option java_outer_classname = "SpannerProto"; option java_package = "com.google.spanner.v1"; option php_namespace = "Google\\Cloud\\Spanner\\V1"; - -// The Database resource is defined in `google.spanner.admin.database.v1`. -// Because this is a separate, independent API (technically), we redefine -// the resource name pattern here. option (google.api.resource_definition) = { type: "spanner.googleapis.com/Database" pattern: "projects/{project}/instances/{instance}/databases/{database}" @@ -69,7 +64,7 @@ service Spanner { // // Active sessions use additional server resources, so it is a good idea to // delete idle and unneeded sessions. - // Aside from explicit deletes, Cloud Spanner can delete sessions for which no + // Aside from explicit deletes, Cloud Spanner may delete sessions for which no // operations are sent for more than an hour. If a session is deleted, // requests to it return `NOT_FOUND`. // @@ -87,8 +82,7 @@ service Spanner { // // This API can be used to initialize a session cache on the clients. // See https://goo.gl/TgSFN2 for best practices on session cache management. - rpc BatchCreateSessions(BatchCreateSessionsRequest) - returns (BatchCreateSessionsResponse) { + rpc BatchCreateSessions(BatchCreateSessionsRequest) returns (BatchCreateSessionsResponse) { option (google.api.http) = { post: "/v1/{database=projects/*/instances/*/databases/*}/sessions:batchCreate" body: "*" @@ -131,12 +125,10 @@ service Spanner { // // 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. + // 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. + // [ExecuteStreamingSql][google.spanner.v1.Spanner.ExecuteStreamingSql] instead. rpc ExecuteSql(ExecuteSqlRequest) returns (ResultSet) { option (google.api.http) = { post: "/v1/{session=projects/*/instances/*/databases/*/sessions/*}:executeSql" @@ -144,11 +136,11 @@ service Spanner { }; } - // 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. + // 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. rpc ExecuteStreamingSql(ExecuteSqlRequest) returns (stream PartialResultSet) { option (google.api.http) = { post: "/v1/{session=projects/*/instances/*/databases/*/sessions/*}:executeStreamingSql" @@ -161,15 +153,13 @@ service Spanner { // [ExecuteSql][google.spanner.v1.Spanner.ExecuteSql]. // // Statements are executed in sequential order. A request can succeed even if - // a statement fails. The - // [ExecuteBatchDmlResponse.status][google.spanner.v1.ExecuteBatchDmlResponse.status] - // field in the response provides information about the statement that failed. - // Clients must inspect this field to determine whether an error occurred. + // a statement fails. The [ExecuteBatchDmlResponse.status][google.spanner.v1.ExecuteBatchDmlResponse.status] field in the + // response provides information about the statement that failed. Clients must + // inspect this field to determine whether an error occurred. // // Execution stops after the first failed statement; the remaining statements // are not executed. - rpc ExecuteBatchDml(ExecuteBatchDmlRequest) - returns (ExecuteBatchDmlResponse) { + rpc ExecuteBatchDml(ExecuteBatchDmlRequest) returns (ExecuteBatchDmlResponse) { option (google.api.http) = { post: "/v1/{session=projects/*/instances/*/databases/*/sessions/*}:executeBatchDml" body: "*" @@ -178,15 +168,14 @@ service Spanner { // 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 + // [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. + // 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. @@ -197,9 +186,9 @@ service Spanner { }; } - // 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 + // 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. rpc StreamingRead(ReadRequest) returns (stream PartialResultSet) { @@ -210,8 +199,7 @@ service Spanner { } // Begins a new transaction. This step can often be skipped: - // [Read][google.spanner.v1.Spanner.Read], - // [ExecuteSql][google.spanner.v1.Spanner.ExecuteSql] and + // [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. rpc BeginTransaction(BeginTransactionRequest) returns (Transaction) { @@ -236,15 +224,13 @@ service Spanner { body: "*" }; option (google.api.method_signature) = "session,transaction_id,mutations"; - option (google.api.method_signature) = - "session,single_use_transaction,mutations"; + option (google.api.method_signature) = "session,single_use_transaction,mutations"; } // 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. + // [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 @@ -259,11 +245,10 @@ service Spanner { // 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. + // 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, is idle for too long, begins a new transaction, or becomes too @@ -278,13 +263,12 @@ service Spanner { // 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. 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. + // 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. 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 @@ -312,8 +296,7 @@ message CreateSessionRequest { Session session = 2; } -// The request for -// [BatchCreateSessions][google.spanner.v1.Spanner.BatchCreateSessions]. +// The request for [BatchCreateSessions][google.spanner.v1.Spanner.BatchCreateSessions]. message BatchCreateSessionsRequest { // Required. The database in which the new sessions are created. string database = 1 [ @@ -330,13 +313,11 @@ message BatchCreateSessionsRequest { // The API may return fewer than the requested number of sessions. If a // specific number of sessions are desired, the client can make additional // calls to BatchCreateSessions (adjusting - // [session_count][google.spanner.v1.BatchCreateSessionsRequest.session_count] - // as necessary). + // [session_count][google.spanner.v1.BatchCreateSessionsRequest.session_count] as necessary). int32 session_count = 3 [(google.api.field_behavior) = REQUIRED]; } -// The response for -// [BatchCreateSessions][google.spanner.v1.Spanner.BatchCreateSessions]. +// The response for [BatchCreateSessions][google.spanner.v1.Spanner.BatchCreateSessions]. message BatchCreateSessionsResponse { // The freshly created sessions. repeated Session session = 1; @@ -377,7 +358,9 @@ message GetSessionRequest { // Required. The name of the session to retrieve. string name = 1 [ (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { type: "spanner.googleapis.com/Session" } + (google.api.resource_reference) = { + type: "spanner.googleapis.com/Session" + } ]; } @@ -396,8 +379,7 @@ message ListSessionsRequest { int32 page_size = 2; // If non-empty, `page_token` should contain a - // [next_page_token][google.spanner.v1.ListSessionsResponse.next_page_token] - // from a previous + // [next_page_token][google.spanner.v1.ListSessionsResponse.next_page_token] from a previous // [ListSessionsResponse][google.spanner.v1.ListSessionsResponse]. string page_token = 3; @@ -420,8 +402,8 @@ message ListSessionsResponse { repeated Session sessions = 1; // `next_page_token` can be sent in a subsequent - // [ListSessions][google.spanner.v1.Spanner.ListSessions] call to fetch more - // of the matching sessions. + // [ListSessions][google.spanner.v1.Spanner.ListSessions] call to fetch more of the matching + // sessions. string next_page_token = 2; } @@ -430,13 +412,36 @@ message DeleteSessionRequest { // Required. The name of the session to delete. string name = 1 [ (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { type: "spanner.googleapis.com/Session" } + (google.api.resource_reference) = { + type: "spanner.googleapis.com/Session" + } ]; } // The request for [ExecuteSql][google.spanner.v1.Spanner.ExecuteSql] and // [ExecuteStreamingSql][google.spanner.v1.Spanner.ExecuteStreamingSql]. message ExecuteSqlRequest { + // Query optimizer configuration. + message QueryOptions { + // An option to control the selection of optimizer version. + // + // This parameter allows individual queries to pick different query + // optimizer versions. + // + // Specifying "latest" as a value instructs Cloud Spanner to use the + // latest supported query optimizer version. If not specified, Cloud Spanner + // uses optimizer version set at the database level options. Any other + // positive integer (from the list of supported optimizer versions) + // overrides the default optimizer version for query execution. + // The list of supported optimizer versions can be queried from + // SPANNER_SYS.SUPPORTED_OPTIMIZER_VERSIONS. Executing a SQL statement + // with an invalid optimizer version will fail with a syntax error + // (`INVALID_ARGUMENT`) status. + // + // The `optimizer_version` statement hint has precedence over this setting. + string optimizer_version = 1; + } + // Mode in which the statement must be processed. enum QueryMode { // The default mode. Only the statement results are returned. @@ -454,7 +459,9 @@ message ExecuteSqlRequest { // Required. The session in which the SQL query should be performed. string session = 1 [ (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { type: "spanner.googleapis.com/Session" } + (google.api.resource_reference) = { + type: "spanner.googleapis.com/Session" + } ]; // The transaction to use. @@ -488,8 +495,7 @@ message ExecuteSqlRequest { // 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. + // 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 statement parameters. See the @@ -499,18 +505,15 @@ message ExecuteSqlRequest { // 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 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. + // [PartialResultSet][google.spanner.v1.PartialResultSet] yielded 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. bytes resume_token = 6; // Used to control the amount of debugging information returned in - // [ResultSetStats][google.spanner.v1.ResultSetStats]. If - // [partition_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.ExecuteSqlRequest.QueryMode.NORMAL]. + // [ResultSetStats][google.spanner.v1.ResultSetStats]. If [partition_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.ExecuteSqlRequest.QueryMode.NORMAL]. QueryMode query_mode = 7; // If present, results will be restricted to the specified partition @@ -530,6 +533,9 @@ message ExecuteSqlRequest { // // Required for DML statements. Ignored for queries. int64 seqno = 9; + + // Query optimizer configuration to use for the given query. + QueryOptions query_options = 10; } // The request for [ExecuteBatchDml][google.spanner.v1.Spanner.ExecuteBatchDml]. @@ -555,9 +561,7 @@ message ExecuteBatchDmlRequest { // 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.ExecuteBatchDmlRequest.Statement.params] as - // JSON strings. + // of type `STRING` both appear in [params][google.spanner.v1.ExecuteBatchDmlRequest.Statement.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 statement parameters. See the @@ -569,7 +573,9 @@ message ExecuteBatchDmlRequest { // Required. The session in which the DML statements should be performed. string session = 1 [ (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { type: "spanner.googleapis.com/Session" } + (google.api.resource_reference) = { + type: "spanner.googleapis.com/Session" + } ]; // Required. The transaction to use. Must be a read-write transaction. @@ -579,17 +585,17 @@ message ExecuteBatchDmlRequest { // transaction. TransactionSelector transaction = 2 [(google.api.field_behavior) = REQUIRED]; - // Required. The list of statements to execute in this batch. Statements are - // executed serially, such that the effects of statement `i` are visible to - // statement `i+1`. Each statement must be a DML statement. Execution stops at - // the first failed statement; the remaining statements are not executed. + // Required. The list of statements to execute in this batch. Statements are executed + // serially, such that the effects of statement `i` are visible to statement + // `i+1`. Each statement must be a DML statement. Execution stops at the + // first failed statement; the remaining statements are not executed. // // Callers must provide at least one statement. repeated Statement statements = 3 [(google.api.field_behavior) = REQUIRED]; - // Required. A per-transaction sequence number used to identify this request. - // This field makes each request idempotent such that if the request is - // received multiple times, at most one will succeed. + // Required. A per-transaction sequence number used to identify this request. This field + // 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 @@ -598,47 +604,38 @@ message ExecuteBatchDmlRequest { int64 seqno = 4 [(google.api.field_behavior) = REQUIRED]; } -// The response for -// [ExecuteBatchDml][google.spanner.v1.Spanner.ExecuteBatchDml]. Contains a list -// of [ResultSet][google.spanner.v1.ResultSet] messages, one for each DML -// statement that has successfully executed, in the same order as the statements -// in the request. If a statement fails, the status in the response body -// identifies the cause of the failure. +// The response for [ExecuteBatchDml][google.spanner.v1.Spanner.ExecuteBatchDml]. Contains a list +// of [ResultSet][google.spanner.v1.ResultSet] messages, one for each DML statement that has successfully +// executed, in the same order as the statements in the request. If a statement +// fails, the status in the response body identifies the cause of the failure. // // To check for DML statements that failed, use the following approach: // -// 1. Check the status in the response message. The -// [google.rpc.Code][google.rpc.Code] enum +// 1. Check the status in the response message. The [google.rpc.Code][google.rpc.Code] enum // value `OK` indicates that all statements were executed successfully. // 2. If the status was not `OK`, check the number of result sets in the -// response. If the response contains `N` -// [ResultSet][google.spanner.v1.ResultSet] messages, then statement `N+1` in -// the request failed. +// response. If the response contains `N` [ResultSet][google.spanner.v1.ResultSet] messages, then +// statement `N+1` in the request failed. // // Example 1: // // * Request: 5 DML statements, all executed successfully. -// * Response: 5 [ResultSet][google.spanner.v1.ResultSet] messages, with the -// status `OK`. +// * Response: 5 [ResultSet][google.spanner.v1.ResultSet] messages, with the status `OK`. // // Example 2: // // * Request: 5 DML statements. The third statement has a syntax error. -// * Response: 2 [ResultSet][google.spanner.v1.ResultSet] messages, and a syntax -// error (`INVALID_ARGUMENT`) -// status. The number of [ResultSet][google.spanner.v1.ResultSet] messages -// indicates that the third statement failed, and the fourth and fifth -// statements were not executed. +// * Response: 2 [ResultSet][google.spanner.v1.ResultSet] messages, and a syntax error (`INVALID_ARGUMENT`) +// status. The number of [ResultSet][google.spanner.v1.ResultSet] messages indicates that the third +// statement failed, and the fourth and fifth statements were not executed. message ExecuteBatchDmlResponse { - // One [ResultSet][google.spanner.v1.ResultSet] for each statement in the - // request that ran successfully, in the same order as the statements in the - // request. Each [ResultSet][google.spanner.v1.ResultSet] does not contain any - // rows. The [ResultSetStats][google.spanner.v1.ResultSetStats] in each - // [ResultSet][google.spanner.v1.ResultSet] contain the number of rows - // modified by the statement. - // - // Only the first [ResultSet][google.spanner.v1.ResultSet] in the response - // contains valid [ResultSetMetadata][google.spanner.v1.ResultSetMetadata]. + // One [ResultSet][google.spanner.v1.ResultSet] for each statement in the request that ran successfully, + // in the same order as the statements in the request. Each [ResultSet][google.spanner.v1.ResultSet] does + // not contain any rows. The [ResultSetStats][google.spanner.v1.ResultSetStats] in each [ResultSet][google.spanner.v1.ResultSet] contain + // the number of rows modified by the statement. + // + // Only the first [ResultSet][google.spanner.v1.ResultSet] in the response contains valid + // [ResultSetMetadata][google.spanner.v1.ResultSetMetadata]. repeated ResultSet result_sets = 1; // If all DML statements are executed successfully, the status is `OK`. @@ -673,23 +670,24 @@ message PartitionQueryRequest { // Required. The session used to create the partitions. string session = 1 [ (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { type: "spanner.googleapis.com/Session" } + (google.api.resource_reference) = { + type: "spanner.googleapis.com/Session" + } ]; // Read only snapshot transactions are supported, read/write and single use // transactions are not. TransactionSelector transaction = 2; - // Required. The query request to generate partitions for. The request will - // fail if the query is not root partitionable. The query plan of a root + // Required. The query request to generate partitions for. The request will fail if + // the query is not root partitionable. The query plan of a root // partitionable query has a single distributed union 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. // // This must not contain DML commands, such as INSERT, UPDATE, or - // DELETE. Use - // [ExecuteStreamingSql][google.spanner.v1.Spanner.ExecuteStreamingSql] with a + // DELETE. Use [ExecuteStreamingSql][google.spanner.v1.Spanner.ExecuteStreamingSql] with a // PartitionedDml transaction for large, partition-friendly DML operations. string sql = 3 [(google.api.field_behavior) = REQUIRED]; @@ -709,8 +707,7 @@ message PartitionQueryRequest { // 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.PartitionQueryRequest.params] as JSON strings. + // of type `STRING` both appear in [params][google.spanner.v1.PartitionQueryRequest.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 @@ -727,7 +724,9 @@ message PartitionReadRequest { // Required. The session used to create the partitions. string session = 1 [ (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { type: "spanner.googleapis.com/Session" } + (google.api.resource_reference) = { + type: "spanner.googleapis.com/Session" + } ]; // Read only snapshot transactions are supported, read/write and single use @@ -737,24 +736,18 @@ message PartitionReadRequest { // Required. The name of the table in the database to be read. string table = 3 [(google.api.field_behavior) = REQUIRED]; - // If non-empty, the name of an index on - // [table][google.spanner.v1.PartitionReadRequest.table]. This index is used - // instead of the table primary key when interpreting - // [key_set][google.spanner.v1.PartitionReadRequest.key_set] and sorting - // result rows. See [key_set][google.spanner.v1.PartitionReadRequest.key_set] - // for further information. + // If non-empty, the name of an index on [table][google.spanner.v1.PartitionReadRequest.table]. This index is + // used instead of the table primary key when interpreting [key_set][google.spanner.v1.PartitionReadRequest.key_set] + // and sorting result rows. See [key_set][google.spanner.v1.PartitionReadRequest.key_set] for further information. string index = 4; - // The columns of [table][google.spanner.v1.PartitionReadRequest.table] to be - // returned for each row matching this request. + // The columns of [table][google.spanner.v1.PartitionReadRequest.table] to be returned for each row matching + // this request. repeated string columns = 5; // Required. `key_set` identifies the rows to be yielded. `key_set` names the - // primary keys of the rows in - // [table][google.spanner.v1.PartitionReadRequest.table] to be yielded, unless - // [index][google.spanner.v1.PartitionReadRequest.index] is present. If - // [index][google.spanner.v1.PartitionReadRequest.index] is present, then - // [key_set][google.spanner.v1.PartitionReadRequest.key_set] instead names + // primary keys of the rows in [table][google.spanner.v1.PartitionReadRequest.table] to be yielded, unless [index][google.spanner.v1.PartitionReadRequest.index] + // is present. If [index][google.spanner.v1.PartitionReadRequest.index] is present, then [key_set][google.spanner.v1.PartitionReadRequest.key_set] instead names // index keys in [index][google.spanner.v1.PartitionReadRequest.index]. // // It is not an error for the `key_set` to name rows that do not @@ -790,7 +783,9 @@ message ReadRequest { // Required. The session in which the read should be performed. string session = 1 [ (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { type: "spanner.googleapis.com/Session" } + (google.api.resource_reference) = { + type: "spanner.googleapis.com/Session" + } ]; // The transaction to use. If none is provided, the default is a @@ -800,31 +795,24 @@ message ReadRequest { // Required. The name of the table in the database to be read. string table = 3 [(google.api.field_behavior) = REQUIRED]; - // If non-empty, the name of an index on - // [table][google.spanner.v1.ReadRequest.table]. This index is used instead of - // the table primary key when interpreting - // [key_set][google.spanner.v1.ReadRequest.key_set] and sorting result rows. - // See [key_set][google.spanner.v1.ReadRequest.key_set] for further - // information. + // If non-empty, the name of an index on [table][google.spanner.v1.ReadRequest.table]. This index is + // used instead of the table primary key when interpreting [key_set][google.spanner.v1.ReadRequest.key_set] + // and sorting result rows. See [key_set][google.spanner.v1.ReadRequest.key_set] for further information. string index = 4; - // Required. The columns of [table][google.spanner.v1.ReadRequest.table] to be - // returned for each row matching this request. + // Required. The columns of [table][google.spanner.v1.ReadRequest.table] to be returned for each row matching + // this request. repeated string columns = 5 [(google.api.field_behavior) = REQUIRED]; // Required. `key_set` identifies the rows to be yielded. `key_set` names the - // primary keys of the rows in [table][google.spanner.v1.ReadRequest.table] to - // be yielded, unless [index][google.spanner.v1.ReadRequest.index] is present. - // If [index][google.spanner.v1.ReadRequest.index] is present, then - // [key_set][google.spanner.v1.ReadRequest.key_set] instead names index keys - // in [index][google.spanner.v1.ReadRequest.index]. - // - // If the [partition_token][google.spanner.v1.ReadRequest.partition_token] - // field is empty, rows are yielded in table primary key order (if - // [index][google.spanner.v1.ReadRequest.index] is empty) or index key order - // (if [index][google.spanner.v1.ReadRequest.index] is non-empty). If the - // [partition_token][google.spanner.v1.ReadRequest.partition_token] field is - // not empty, rows will be yielded in an unspecified order. + // primary keys of the rows in [table][google.spanner.v1.ReadRequest.table] to be yielded, unless [index][google.spanner.v1.ReadRequest.index] + // is present. If [index][google.spanner.v1.ReadRequest.index] is present, then [key_set][google.spanner.v1.ReadRequest.key_set] instead names + // index keys in [index][google.spanner.v1.ReadRequest.index]. + // + // If the [partition_token][google.spanner.v1.ReadRequest.partition_token] field is empty, rows are yielded + // in table primary key order (if [index][google.spanner.v1.ReadRequest.index] is empty) or index key order + // (if [index][google.spanner.v1.ReadRequest.index] is non-empty). If the [partition_token][google.spanner.v1.ReadRequest.partition_token] field is not + // empty, rows will be yielded in an unspecified order. // // It is not an error for the `key_set` to name rows that do not // exist in the database. Read yields nothing for nonexistent rows. @@ -837,9 +825,9 @@ message ReadRequest { // If this request is resuming a previously interrupted read, // `resume_token` should be copied from the last - // [PartialResultSet][google.spanner.v1.PartialResultSet] yielded before the - // interruption. Doing this enables the new read to resume where the last read - // left off. The rest of the request parameters must exactly match the request + // [PartialResultSet][google.spanner.v1.PartialResultSet] yielded before the interruption. Doing this + // enables the new read to resume where the last read left off. The + // rest of the request parameters must exactly match the request // that yielded this token. bytes resume_token = 9; @@ -850,13 +838,14 @@ message ReadRequest { bytes partition_token = 10; } -// The request for -// [BeginTransaction][google.spanner.v1.Spanner.BeginTransaction]. +// The request for [BeginTransaction][google.spanner.v1.Spanner.BeginTransaction]. message BeginTransactionRequest { // Required. The session in which the transaction runs. string session = 1 [ (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { type: "spanner.googleapis.com/Session" } + (google.api.resource_reference) = { + type: "spanner.googleapis.com/Session" + } ]; // Required. Options for the new transaction. @@ -868,7 +857,9 @@ message CommitRequest { // Required. The session in which the transaction to be committed is running. string session = 1 [ (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { type: "spanner.googleapis.com/Session" } + (google.api.resource_reference) = { + type: "spanner.googleapis.com/Session" + } ]; // Required. The transaction in which to commit. @@ -905,7 +896,9 @@ message RollbackRequest { // Required. The session in which the transaction to roll back is running. string session = 1 [ (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { type: "spanner.googleapis.com/Session" } + (google.api.resource_reference) = { + type: "spanner.googleapis.com/Session" + } ]; // Required. The transaction to roll back. diff --git a/google/cloud/spanner_v1/proto/spanner_pb2.py b/google/cloud/spanner_v1/proto/spanner_pb2.py index 3415264909..ab1ff4e42e 100644 --- a/google/cloud/spanner_v1/proto/spanner_pb2.py +++ b/google/cloud/spanner_v1/proto/spanner_pb2.py @@ -48,7 +48,7 @@ "\n\025com.google.spanner.v1B\014SpannerProtoP\001Z8google.golang.org/genproto/googleapis/spanner/v1;spanner\252\002\027Google.Cloud.Spanner.V1\312\002\027Google\\Cloud\\Spanner\\V1\352A_\n\037spanner.googleapis.com/Database\022\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"\xb1\x02\n\x14PartitionReadRequest\x12\x37\n\x07session\x18\x01 \x01(\tB&\xe0\x41\x02\xfa\x41 \n\x1espanner.googleapis.com/Session\x12;\n\x0btransaction\x18\x02 \x01(\x0b\x32&.google.spanner.v1.TransactionSelector\x12\x12\n\x05table\x18\x03 \x01(\tB\x03\xe0\x41\x02\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.KeySetB\x03\xe0\x41\x02\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"\xab\x02\n\x0bReadRequest\x12\x37\n\x07session\x18\x01 \x01(\tB&\xe0\x41\x02\xfa\x41 \n\x1espanner.googleapis.com/Session\x12;\n\x0btransaction\x18\x02 \x01(\x0b\x32&.google.spanner.v1.TransactionSelector\x12\x12\n\x05table\x18\x03 \x01(\tB\x03\xe0\x41\x02\x12\r\n\x05index\x18\x04 \x01(\t\x12\x14\n\x07\x63olumns\x18\x05 \x03(\tB\x03\xe0\x41\x02\x12/\n\x07key_set\x18\x06 \x01(\x0b\x32\x19.google.spanner.v1.KeySetB\x03\xe0\x41\x02\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"\x8f\x01\n\x17\x42\x65ginTransactionRequest\x12\x37\n\x07session\x18\x01 \x01(\tB&\xe0\x41\x02\xfa\x41 \n\x1espanner.googleapis.com/Session\x12;\n\x07options\x18\x02 \x01(\x0b\x32%.google.spanner.v1.TransactionOptionsB\x03\xe0\x41\x02"\xea\x01\n\rCommitRequest\x12\x37\n\x07session\x18\x01 \x01(\tB&\xe0\x41\x02\xfa\x41 \n\x1espanner.googleapis.com/Session\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"g\n\x0fRollbackRequest\x12\x37\n\x07session\x18\x01 \x01(\tB&\xe0\x41\x02\xfa\x41 \n\x1espanner.googleapis.com/Session\x12\x1b\n\x0etransaction_id\x18\x02 \x01(\x0c\x42\x03\xe0\x41\x02\x32\xc0\x16\n\x07Spanner\x12\xa6\x01\n\rCreateSession\x12\'.google.spanner.v1.CreateSessionRequest\x1a\x1a.google.spanner.v1.Session"P\x82\xd3\xe4\x93\x02?":/v1/{database=projects/*/instances/*/databases/*}/sessions:\x01*\xda\x41\x08\x64\x61tabase\x12\xe0\x01\n\x13\x42\x61tchCreateSessions\x12-.google.spanner.v1.BatchCreateSessionsRequest\x1a..google.spanner.v1.BatchCreateSessionsResponse"j\x82\xd3\xe4\x93\x02K"F/v1/{database=projects/*/instances/*/databases/*}/sessions:batchCreate:\x01*\xda\x41\x16\x64\x61tabase,session_count\x12\x97\x01\n\nGetSession\x12$.google.spanner.v1.GetSessionRequest\x1a\x1a.google.spanner.v1.Session"G\x82\xd3\xe4\x93\x02:\x12\x38/v1/{name=projects/*/instances/*/databases/*/sessions/*}\xda\x41\x04name\x12\xae\x01\n\x0cListSessions\x12&.google.spanner.v1.ListSessionsRequest\x1a\'.google.spanner.v1.ListSessionsResponse"M\x82\xd3\xe4\x93\x02<\x12:/v1/{database=projects/*/instances/*/databases/*}/sessions\xda\x41\x08\x64\x61tabase\x12\x99\x01\n\rDeleteSession\x12\'.google.spanner.v1.DeleteSessionRequest\x1a\x16.google.protobuf.Empty"G\x82\xd3\xe4\x93\x02:*8/v1/{name=projects/*/instances/*/databases/*/sessions/*}\xda\x41\x04name\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\xc0\x01\n\x0f\x45xecuteBatchDml\x12).google.spanner.v1.ExecuteBatchDmlRequest\x1a*.google.spanner.v1.ExecuteBatchDmlResponse"V\x82\xd3\xe4\x93\x02P"K/v1/{session=projects/*/instances/*/databases/*/sessions/*}:executeBatchDml:\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\xc9\x01\n\x10\x42\x65ginTransaction\x12*.google.spanner.v1.BeginTransactionRequest\x1a\x1e.google.spanner.v1.Transaction"i\x82\xd3\xe4\x93\x02Q"L/v1/{session=projects/*/instances/*/databases/*/sessions/*}:beginTransaction:\x01*\xda\x41\x0fsession,options\x12\xeb\x01\n\x06\x43ommit\x12 .google.spanner.v1.CommitRequest\x1a!.google.spanner.v1.CommitResponse"\x9b\x01\x82\xd3\xe4\x93\x02G"B/v1/{session=projects/*/instances/*/databases/*/sessions/*}:commit:\x01*\xda\x41 session,transaction_id,mutations\xda\x41(session,single_use_transaction,mutations\x12\xb0\x01\n\x08Rollback\x12".google.spanner.v1.RollbackRequest\x1a\x16.google.protobuf.Empty"h\x82\xd3\xe4\x93\x02I"D/v1/{session=projects/*/instances/*/databases/*/sessions/*}:rollback:\x01*\xda\x41\x16session,transaction_id\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*\x1aw\xca\x41\x16spanner.googleapis.com\xd2\x41[https://www.googleapis.com/auth/cloud-platform,https://www.googleapis.com/auth/spanner.dataB\xf7\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\\V1\xea\x41_\n\x1fspanner.googleapis.com/Database\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"\xb1\x02\n\x14PartitionReadRequest\x12\x37\n\x07session\x18\x01 \x01(\tB&\xe0\x41\x02\xfa\x41 \n\x1espanner.googleapis.com/Session\x12;\n\x0btransaction\x18\x02 \x01(\x0b\x32&.google.spanner.v1.TransactionSelector\x12\x12\n\x05table\x18\x03 \x01(\tB\x03\xe0\x41\x02\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.KeySetB\x03\xe0\x41\x02\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"\xab\x02\n\x0bReadRequest\x12\x37\n\x07session\x18\x01 \x01(\tB&\xe0\x41\x02\xfa\x41 \n\x1espanner.googleapis.com/Session\x12;\n\x0btransaction\x18\x02 \x01(\x0b\x32&.google.spanner.v1.TransactionSelector\x12\x12\n\x05table\x18\x03 \x01(\tB\x03\xe0\x41\x02\x12\r\n\x05index\x18\x04 \x01(\t\x12\x14\n\x07\x63olumns\x18\x05 \x03(\tB\x03\xe0\x41\x02\x12/\n\x07key_set\x18\x06 \x01(\x0b\x32\x19.google.spanner.v1.KeySetB\x03\xe0\x41\x02\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"\x8f\x01\n\x17\x42\x65ginTransactionRequest\x12\x37\n\x07session\x18\x01 \x01(\tB&\xe0\x41\x02\xfa\x41 \n\x1espanner.googleapis.com/Session\x12;\n\x07options\x18\x02 \x01(\x0b\x32%.google.spanner.v1.TransactionOptionsB\x03\xe0\x41\x02"\xea\x01\n\rCommitRequest\x12\x37\n\x07session\x18\x01 \x01(\tB&\xe0\x41\x02\xfa\x41 \n\x1espanner.googleapis.com/Session\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"g\n\x0fRollbackRequest\x12\x37\n\x07session\x18\x01 \x01(\tB&\xe0\x41\x02\xfa\x41 \n\x1espanner.googleapis.com/Session\x12\x1b\n\x0etransaction_id\x18\x02 \x01(\x0c\x42\x03\xe0\x41\x02\x32\xc0\x16\n\x07Spanner\x12\xa6\x01\n\rCreateSession\x12\'.google.spanner.v1.CreateSessionRequest\x1a\x1a.google.spanner.v1.Session"P\x82\xd3\xe4\x93\x02?":/v1/{database=projects/*/instances/*/databases/*}/sessions:\x01*\xda\x41\x08\x64\x61tabase\x12\xe0\x01\n\x13\x42\x61tchCreateSessions\x12-.google.spanner.v1.BatchCreateSessionsRequest\x1a..google.spanner.v1.BatchCreateSessionsResponse"j\x82\xd3\xe4\x93\x02K"F/v1/{database=projects/*/instances/*/databases/*}/sessions:batchCreate:\x01*\xda\x41\x16\x64\x61tabase,session_count\x12\x97\x01\n\nGetSession\x12$.google.spanner.v1.GetSessionRequest\x1a\x1a.google.spanner.v1.Session"G\x82\xd3\xe4\x93\x02:\x12\x38/v1/{name=projects/*/instances/*/databases/*/sessions/*}\xda\x41\x04name\x12\xae\x01\n\x0cListSessions\x12&.google.spanner.v1.ListSessionsRequest\x1a\'.google.spanner.v1.ListSessionsResponse"M\x82\xd3\xe4\x93\x02<\x12:/v1/{database=projects/*/instances/*/databases/*}/sessions\xda\x41\x08\x64\x61tabase\x12\x99\x01\n\rDeleteSession\x12\'.google.spanner.v1.DeleteSessionRequest\x1a\x16.google.protobuf.Empty"G\x82\xd3\xe4\x93\x02:*8/v1/{name=projects/*/instances/*/databases/*/sessions/*}\xda\x41\x04name\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\xc0\x01\n\x0f\x45xecuteBatchDml\x12).google.spanner.v1.ExecuteBatchDmlRequest\x1a*.google.spanner.v1.ExecuteBatchDmlResponse"V\x82\xd3\xe4\x93\x02P"K/v1/{session=projects/*/instances/*/databases/*/sessions/*}:executeBatchDml:\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\xc9\x01\n\x10\x42\x65ginTransaction\x12*.google.spanner.v1.BeginTransactionRequest\x1a\x1e.google.spanner.v1.Transaction"i\x82\xd3\xe4\x93\x02Q"L/v1/{session=projects/*/instances/*/databases/*/sessions/*}:beginTransaction:\x01*\xda\x41\x0fsession,options\x12\xeb\x01\n\x06\x43ommit\x12 .google.spanner.v1.CommitRequest\x1a!.google.spanner.v1.CommitResponse"\x9b\x01\x82\xd3\xe4\x93\x02G"B/v1/{session=projects/*/instances/*/databases/*/sessions/*}:commit:\x01*\xda\x41 session,transaction_id,mutations\xda\x41(session,single_use_transaction,mutations\x12\xb0\x01\n\x08Rollback\x12".google.spanner.v1.RollbackRequest\x1a\x16.google.protobuf.Empty"h\x82\xd3\xe4\x93\x02I"D/v1/{session=projects/*/instances/*/databases/*/sessions/*}:rollback:\x01*\xda\x41\x16session,transaction_id\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*\x1aw\xca\x41\x16spanner.googleapis.com\xd2\x41[https://www.googleapis.com/auth/cloud-platform,https://www.googleapis.com/auth/spanner.dataB\xf7\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\\V1\xea\x41_\n\x1fspanner.googleapis.com/Database\x12