From a48c4b1c669e62232244315e9f509fc309388c2c Mon Sep 17 00:00:00 2001 From: Yoshi Automation Bot Date: Thu, 12 Mar 2020 17:30:38 -0700 Subject: [PATCH] chore: add backups (via synth) Co-authored-by: larkee <31196561+larkee@users.noreply.github.com> --- .../gapic/database_admin_client.py | 941 ++++++++++- .../gapic/database_admin_client_config.py | 40 + .../spanner_admin_database_v1/gapic/enums.py | 38 + .../database_admin_grpc_transport.py | 166 +- .../proto/backup.proto | 363 +++++ .../proto/backup_pb2.py | 1379 +++++++++++++++++ .../proto/backup_pb2_grpc.py | 2 + .../proto/common.proto | 43 + .../proto/common_pb2.py | 151 ++ .../proto/common_pb2_grpc.py | 2 + .../proto/spanner_database_admin.proto | 364 ++++- .../proto/spanner_database_admin_pb2.py | 1174 ++++++++++++-- .../proto/spanner_database_admin_pb2_grpc.py | 210 ++- .../proto/spanner_instance_admin_pb2.py | 4 +- synth.metadata | 12 +- .../gapic/v1/test_database_admin_client_v1.py | 382 +++++ 16 files changed, 5126 insertions(+), 145 deletions(-) create mode 100644 google/cloud/spanner_admin_database_v1/proto/backup.proto create mode 100644 google/cloud/spanner_admin_database_v1/proto/backup_pb2.py create mode 100644 google/cloud/spanner_admin_database_v1/proto/backup_pb2_grpc.py create mode 100644 google/cloud/spanner_admin_database_v1/proto/common.proto create mode 100644 google/cloud/spanner_admin_database_v1/proto/common_pb2.py create mode 100644 google/cloud/spanner_admin_database_v1/proto/common_pb2_grpc.py 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 5ee127d1ef..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 @@ -25,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"; @@ -41,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) = @@ -104,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/*}" @@ -121,11 +126,13 @@ 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]. + // 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" @@ -138,12 +145,14 @@ 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]. + // 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" @@ -156,12 +165,16 @@ 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. + // 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" @@ -173,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. @@ -193,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 @@ -200,10 +356,17 @@ 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]. @@ -256,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 @@ -380,3 +543,184 @@ message GetDatabaseDdlResponse { // 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 2491691e6b..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): @@ -124,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!") @@ -139,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!") @@ -221,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/proto/spanner_instance_admin_pb2.py b/google/cloud/spanner_admin_instance_v1/proto/spanner_instance_admin_pb2.py index d55c007030..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 @@ -1340,8 +1340,8 @@ ), DESCRIPTOR=_INSTANCE, __module__="google.cloud.spanner.admin.instance_v1.proto.spanner_instance_admin_pb2", - __doc__="""An isolated set of Cloud Spanner resources on which databases can be - hosted. + __doc__="""An isolated set of Cloud Spanner resources on which + databases can be hosted. Attributes: diff --git a/synth.metadata b/synth.metadata index 8abfac8f6a..df0f13a1a6 100644 --- a/synth.metadata +++ b/synth.metadata @@ -1,20 +1,20 @@ { - "updateTime": "2020-03-03T13:26:45.038429Z", + "updateTime": "2020-03-12T12:14:50.181539Z", "sources": [ { "generator": { "name": "artman", - "version": "0.47.0", - "dockerImage": "googleapis/artman@sha256:b3e50d6b8de03920b9f065bbc3d210e2ca93a043446f1fa16cdf567393c09678" + "version": "1.1.0", + "dockerImage": "googleapis/artman@sha256:f54b7644a1d2e7a37b23f5c0dfe9bba473e41c675002a507a244389e27487ca9" } }, { "git": { "name": "googleapis", "remote": "https://github.com/googleapis/googleapis.git", - "sha": "4a180bfff8a21645b3a935c2756e8d6ab18a74e0", - "internalRef": "298484782", - "log": "4a180bfff8a21645b3a935c2756e8d6ab18a74e0\nautoml/v1beta1 publish proto updates\n\nPiperOrigin-RevId: 298484782\n\n6de6e938b7df1cd62396563a067334abeedb9676\nchore: use the latest gapic-generator and protoc-java-resource-name-plugin in Bazel workspace.\n\nPiperOrigin-RevId: 298474513\n\n244ab2b83a82076a1fa7be63b7e0671af73f5c02\nAdds service config definition for bigqueryreservation v1\n\nPiperOrigin-RevId: 298455048\n\n83c6f84035ee0f80eaa44d8b688a010461cc4080\nUpdate google/api/auth.proto to make AuthProvider to have JwtLocation\n\nPiperOrigin-RevId: 297918498\n\ne9e90a787703ec5d388902e2cb796aaed3a385b4\nDialogflow weekly v2/v2beta1 library update:\n - adding get validation result\n - adding field mask override control for output audio config\nImportant updates are also posted at:\nhttps://cloud.google.com/dialogflow/docs/release-notes\n\nPiperOrigin-RevId: 297671458\n\n1a2b05cc3541a5f7714529c665aecc3ea042c646\nAdding .yaml and .json config files.\n\nPiperOrigin-RevId: 297570622\n\ndfe1cf7be44dee31d78f78e485d8c95430981d6e\nPublish `QueryOptions` proto.\n\nIntroduced a `query_options` input in `ExecuteSqlRequest`.\n\nPiperOrigin-RevId: 297497710\n\ndafc905f71e5d46f500b41ed715aad585be062c3\npubsub: revert pull init_rpc_timeout & max_rpc_timeout back to 25 seconds and reset multiplier to 1.0\n\nPiperOrigin-RevId: 297486523\n\nf077632ba7fee588922d9e8717ee272039be126d\nfirestore: add update_transform\n\nPiperOrigin-RevId: 297405063\n\n0aba1900ffef672ec5f0da677cf590ee5686e13b\ncluster: use square brace for cross-reference\n\nPiperOrigin-RevId: 297204568\n\n5dac2da18f6325cbaed54603c43f0667ecd50247\nRestore retry params in gapic config because securitycenter has non-standard default retry params.\nRestore a few retry codes for some idempotent methods.\n\nPiperOrigin-RevId: 297196720\n\n1eb61455530252bba8b2c8d4bc9832960e5a56f6\npubsub: v1 replace IAM HTTP rules\n\nPiperOrigin-RevId: 297188590\n\n80b2d25f8d43d9d47024ff06ead7f7166548a7ba\nDialogflow weekly v2/v2beta1 library update:\n - updates to mega agent api\n - adding field mask override control for output audio config\nImportant updates are also posted at:\nhttps://cloud.google.com/dialogflow/docs/release-notes\n\nPiperOrigin-RevId: 297187629\n\n0b1876b35e98f560f9c9ca9797955f020238a092\nUse an older version of protoc-docs-plugin that is compatible with the specified gapic-generator and protobuf versions.\n\nprotoc-docs-plugin >=0.4.0 (see commit https://github.com/googleapis/protoc-docs-plugin/commit/979f03ede6678c487337f3d7e88bae58df5207af) is incompatible with protobuf 3.9.1.\n\nPiperOrigin-RevId: 296986742\n\n1e47e676cddbbd8d93f19ba0665af15b5532417e\nFix: Restore a method signature for UpdateCluster\n\nPiperOrigin-RevId: 296901854\n\n7f910bcc4fc4704947ccfd3ceed015d16b9e00c2\nUpdate Dataproc v1beta2 client.\n\nPiperOrigin-RevId: 296451205\n\nde287524405a3dce124d301634731584fc0432d7\nFix: Reinstate method signatures that had been missed off some RPCs\nFix: Correct resource types for two fields\n\nPiperOrigin-RevId: 296435091\n\ne5bc9566ae057fb4c92f8b7e047f1c8958235b53\nDeprecate the endpoint_uris field, as it is unused.\n\nPiperOrigin-RevId: 296357191\n\n8c12e2b4dca94e12bff9f538bdac29524ff7ef7a\nUpdate Dataproc v1 client.\n\nPiperOrigin-RevId: 296336662\n\n17567c4a1ef0a9b50faa87024d66f8acbb561089\nRemoving erroneous comment, a la https://github.com/googleapis/java-speech/pull/103\n\nPiperOrigin-RevId: 296332968\n\n3eaaaf8626ce5b0c0bc7eee05e143beffa373b01\nAdd BUILD.bazel for v1 secretmanager.googleapis.com\n\nPiperOrigin-RevId: 296274723\n\ne76149c3d992337f85eeb45643106aacae7ede82\nMove securitycenter v1 to use generate from annotations.\n\nPiperOrigin-RevId: 296266862\n\n203740c78ac69ee07c3bf6be7408048751f618f8\nAdd StackdriverLoggingConfig field to Cloud Tasks v2 API.\n\nPiperOrigin-RevId: 296256388\n\ne4117d5e9ed8bbca28da4a60a94947ca51cb2083\nCreate a Bazel BUILD file for the google.actions.type export.\n\nPiperOrigin-RevId: 296212567\n\na9639a0a9854fd6e1be08bba1ac3897f4f16cb2f\nAdd secretmanager.googleapis.com v1 protos\n\nPiperOrigin-RevId: 295983266\n\nce4f4c21d9dd2bfab18873a80449b9d9851efde8\nasset: v1p1beta1 remove SearchResources and SearchIamPolicies\n\nPiperOrigin-RevId: 295861722\n\ncb61d6c2d070b589980c779b68ffca617f789116\nasset: v1p1beta1 remove SearchResources and SearchIamPolicies\n\nPiperOrigin-RevId: 295855449\n\nab2685d8d3a0e191dc8aef83df36773c07cb3d06\nfix: Dataproc v1 - AutoscalingPolicy annotation\n\nThis adds the second resource name pattern to the\nAutoscalingPolicy resource.\n\nCommitter: @lukesneeringer\nPiperOrigin-RevId: 295738415\n\n8a1020bf6828f6e3c84c3014f2c51cb62b739140\nUpdate cloud asset api v1p4beta1.\n\nPiperOrigin-RevId: 295286165\n\n5cfa105206e77670369e4b2225597386aba32985\nAdd service control related proto build rule.\n\nPiperOrigin-RevId: 295262088\n\nee4dddf805072004ab19ac94df2ce669046eec26\nmonitoring v3: Add prefix \"https://cloud.google.com/\" into the link for global access\ncl 295167522, get ride of synth.py hacks\n\nPiperOrigin-RevId: 295238095\n\nd9835e922ea79eed8497db270d2f9f85099a519c\nUpdate some minor docs changes about user event proto\n\nPiperOrigin-RevId: 295185610\n\n5f311e416e69c170243de722023b22f3df89ec1c\nfix: use correct PHP package name in gapic configuration\n\nPiperOrigin-RevId: 295161330\n\n6cdd74dcdb071694da6a6b5a206e3a320b62dd11\npubsub: v1 add client config annotations and retry config\n\nPiperOrigin-RevId: 295158776\n\n5169f46d9f792e2934d9fa25c36d0515b4fd0024\nAdded cloud asset api v1p4beta1.\n\nPiperOrigin-RevId: 295026522\n\n56b55aa8818cd0a532a7d779f6ef337ba809ccbd\nFix: Resource annotations for CreateTimeSeriesRequest and ListTimeSeriesRequest should refer to valid resources. TimeSeries is not a named resource.\n\nPiperOrigin-RevId: 294931650\n\n0646bc775203077226c2c34d3e4d50cc4ec53660\nRemove unnecessary languages from bigquery-related artman configuration files.\n\nPiperOrigin-RevId: 294809380\n\n8b78aa04382e3d4147112ad6d344666771bb1909\nUpdate backend.proto for schemes and protocol\n\nPiperOrigin-RevId: 294788800\n\n80b8f8b3de2359831295e24e5238641a38d8488f\nAdds artman config files for bigquerystorage endpoints v1beta2, v1alpha2, v1\n\nPiperOrigin-RevId: 294763931\n\n2c17ac33b226194041155bb5340c3f34733f1b3a\nAdd parameter to sample generated for UpdateInstance. Related to https://github.com/googleapis/python-redis/issues/4\n\nPiperOrigin-RevId: 294734008\n\nd5e8a8953f2acdfe96fb15e85eb2f33739623957\nMove bigquery datatransfer to gapic v2.\n\nPiperOrigin-RevId: 294703703\n\nefd36705972cfcd7d00ab4c6dfa1135bafacd4ae\nfix: Add two annotations that we missed.\n\nPiperOrigin-RevId: 294664231\n\n8a36b928873ff9c05b43859b9d4ea14cd205df57\nFix: Define the \"bigquery.googleapis.com/Table\" resource in the BigQuery Storage API (v1beta2).\n\nPiperOrigin-RevId: 294459768\n\nc7a3caa2c40c49f034a3c11079dd90eb24987047\nFix: Define the \"bigquery.googleapis.com/Table\" resource in the BigQuery Storage API (v1).\n\nPiperOrigin-RevId: 294456889\n\n5006247aa157e59118833658084345ee59af7c09\nFix: Make deprecated fields optional\nFix: Deprecate SetLoggingServiceRequest.zone in line with the comments\nFeature: Add resource name method signatures where appropriate\n\nPiperOrigin-RevId: 294383128\n\neabba40dac05c5cbe0fca3a35761b17e372036c4\nFix: C# and PHP package/namespace capitalization for BigQuery Storage v1.\n\nPiperOrigin-RevId: 294382444\n\nf8d9a858a7a55eba8009a23aa3f5cc5fe5e88dde\nfix: artman configuration file for bigtable-admin\n\nPiperOrigin-RevId: 294322616\n\n0f29555d1cfcf96add5c0b16b089235afbe9b1a9\nAPI definition for (not-yet-launched) GCS gRPC.\n\nPiperOrigin-RevId: 294321472\n\nfcc86bee0e84dc11e9abbff8d7c3529c0626f390\nfix: Bigtable Admin v2\n\nChange LRO metadata from PartialUpdateInstanceMetadata\nto UpdateInstanceMetadata. (Otherwise, it will not build.)\n\nPiperOrigin-RevId: 294264582\n\n6d9361eae2ebb3f42d8c7ce5baf4bab966fee7c0\nrefactor: Add annotations to Bigtable Admin v2.\n\nPiperOrigin-RevId: 294243406\n\nad7616f3fc8e123451c8b3a7987bc91cea9e6913\nFix: Resource type in CreateLogMetricRequest should use logging.googleapis.com.\nFix: ListLogEntries should have a method signature for convenience of calling it.\n\nPiperOrigin-RevId: 294222165\n\n63796fcbb08712676069e20a3e455c9f7aa21026\nFix: Remove extraneous resource definition for cloudkms.googleapis.com/CryptoKey.\n\nPiperOrigin-RevId: 294176658\n\ne7d8a694f4559201e6913f6610069cb08b39274e\nDepend on the latest gapic-generator and resource names plugin.\n\nThis fixes the very old an very annoying bug: https://github.com/googleapis/gapic-generator/pull/3087\n\nPiperOrigin-RevId: 293903652\n\n806b2854a966d55374ee26bb0cef4e30eda17b58\nfix: correct capitalization of Ruby namespaces in SecurityCenter V1p1beta1\n\nPiperOrigin-RevId: 293903613\n\n1b83c92462b14d67a7644e2980f723112472e03a\nPublish annotations and grpc service config for Logging API.\n\nPiperOrigin-RevId: 293893514\n\ne46f761cd6ec15a9e3d5ed4ff321a4bcba8e8585\nGenerate the Bazel build file for recommendengine public api\n\nPiperOrigin-RevId: 293710856\n\n68477017c4173c98addac0373950c6aa9d7b375f\nMake `language_code` optional for UpdateIntentRequest and BatchUpdateIntentsRequest.\n\nThe comments and proto annotations describe this parameter as optional.\n\nPiperOrigin-RevId: 293703548\n\n16f823f578bca4e845a19b88bb9bc5870ea71ab2\nAdd BUILD.bazel files for managedidentities API\n\nPiperOrigin-RevId: 293698246\n\n2f53fd8178c9a9de4ad10fae8dd17a7ba36133f2\nAdd v1p1beta1 config file\n\nPiperOrigin-RevId: 293696729\n\n052b274138fce2be80f97b6dcb83ab343c7c8812\nAdd source field for user event and add field behavior annotations\n\nPiperOrigin-RevId: 293693115\n\n1e89732b2d69151b1b3418fff3d4cc0434f0dded\ndatacatalog: v1beta1 add three new RPCs to gapic v1beta1 config\n\nPiperOrigin-RevId: 293692823\n\n9c8bd09bbdc7c4160a44f1fbab279b73cd7a2337\nchange the name of AccessApproval service to AccessApprovalAdmin\n\nPiperOrigin-RevId: 293690934\n\n2e23b8fbc45f5d9e200572ca662fe1271bcd6760\nAdd ListEntryGroups method, add http bindings to support entry group tagging, and update some comments.\n\nPiperOrigin-RevId: 293666452\n\n0275e38a4ca03a13d3f47a9613aac8c8b0d3f1f2\nAdd proto_package field to managedidentities API. It is needed for APIs that still depend on artman generation.\n\nPiperOrigin-RevId: 293643323\n\n4cdfe8278cb6f308106580d70648001c9146e759\nRegenerating public protos for Data Catalog to add new Custom Type Entry feature.\n\nPiperOrigin-RevId: 293614782\n\n45d2a569ab526a1fad3720f95eefb1c7330eaada\nEnable client generation for v1 ManagedIdentities API.\n\nPiperOrigin-RevId: 293515675\n\n2c17086b77e6f3bcf04a1f65758dfb0c3da1568f\nAdd the Actions on Google common types (//google/actions/type/*).\n\nPiperOrigin-RevId: 293478245\n\n781aadb932e64a12fb6ead7cd842698d99588433\nDialogflow weekly v2/v2beta1 library update:\n- Documentation updates\nImportant updates are also posted at\nhttps://cloud.google.com/dialogflow/docs/release-notes\n\nPiperOrigin-RevId: 293443396\n\ne2602608c9138c2fca24162720e67f9307c30b95\nDialogflow weekly v2/v2beta1 library update:\n- Documentation updates\nImportant updates are also posted at\nhttps://cloud.google.com/dialogflow/docs/release-notes\n\nPiperOrigin-RevId: 293442964\n\nc8aef82028d06b7992278fa9294c18570dc86c3d\nAdd cc_proto_library and cc_grpc_library targets for Bigtable protos.\n\nAlso fix indentation of cc_grpc_library targets in Spanner and IAM protos.\n\nPiperOrigin-RevId: 293440538\n\ne2faab04f4cb7f9755072330866689b1943a16e9\ncloudtasks: v2 replace non-standard retry params in gapic config v2\n\nPiperOrigin-RevId: 293424055\n\ndfb4097ea628a8470292c6590a4313aee0c675bd\nerrorreporting: v1beta1 add legacy artman config for php\n\nPiperOrigin-RevId: 293423790\n\nb18aed55b45bfe5b62476292c72759e6c3e573c6\nasset: v1p1beta1 updated comment for `page_size` limit.\n\nPiperOrigin-RevId: 293421386\n\nc9ef36b7956d9859a2fc86ad35fcaa16958ab44f\nbazel: Refactor CI build scripts\n\nPiperOrigin-RevId: 293387911\n\na8ed9d921fdddc61d8467bfd7c1668f0ad90435c\nfix: set Ruby module name for OrgPolicy\n\nPiperOrigin-RevId: 293257997\n\n6c7d28509bd8315de8af0889688ee20099594269\nredis: v1beta1 add UpgradeInstance and connect_mode field to Instance\n\nPiperOrigin-RevId: 293242878\n\nae0abed4fcb4c21f5cb67a82349a049524c4ef68\nredis: v1 add connect_mode field to Instance\n\nPiperOrigin-RevId: 293241914\n\n3f7a0d29b28ee9365771da2b66edf7fa2b4e9c56\nAdds service config definition for bigqueryreservation v1beta1\n\nPiperOrigin-RevId: 293234418\n\n0c88168d5ed6fe353a8cf8cbdc6bf084f6bb66a5\naddition of BUILD & configuration for accessapproval v1\n\nPiperOrigin-RevId: 293219198\n\n39bedc2e30f4778ce81193f6ba1fec56107bcfc4\naccessapproval: v1 publish protos\n\nPiperOrigin-RevId: 293167048\n\n69d9945330a5721cd679f17331a78850e2618226\nAdd file-level `Session` resource definition\n\nPiperOrigin-RevId: 293080182\n\nf6a1a6b417f39694275ca286110bc3c1ca4db0dc\nAdd file-level `Session` resource definition\n\nPiperOrigin-RevId: 293080178\n\n29d40b78e3dc1579b0b209463fbcb76e5767f72a\nExpose managedidentities/v1beta1/ API for client library usage.\n\nPiperOrigin-RevId: 292979741\n\na22129a1fb6e18056d576dfb7717aef74b63734a\nExpose managedidentities/v1/ API for client library usage.\n\nPiperOrigin-RevId: 292968186\n\n" + "sha": "34a5450c591b6be3d6566f25ac31caa5211b2f3f", + "internalRef": "300474272", + "log": "34a5450c591b6be3d6566f25ac31caa5211b2f3f\nIncreases the default timeout from 20s to 30s for MetricService\n\nPiperOrigin-RevId: 300474272\n\n5d8bffe87cd01ba390c32f1714230e5a95d5991d\nfeat: use the latest gapic-generator in WORKSPACE for bazel build.\n\nPiperOrigin-RevId: 300461878\n\nd631c651e3bcfac5d371e8560c27648f7b3e2364\nUpdated the GAPIC configs to include parameters for Backups APIs.\n\nPiperOrigin-RevId: 300443402\n\n678afc7055c1adea9b7b54519f3bdb228013f918\nAdding Game Servers v1beta API.\n\nPiperOrigin-RevId: 300433218\n\n80d2bd2c652a5e213302041b0620aff423132589\nEnable proto annotation and gapic v2 for talent API.\n\nPiperOrigin-RevId: 300393997\n\n85e454be7a353f7fe1bf2b0affb753305785b872\ndocs(google/maps/roads): remove mention of nonexported api\n\nPiperOrigin-RevId: 300367734\n\nbf839ae632e0f263a729569e44be4b38b1c85f9c\nAdding protocol buffer annotations and updated config info for v1 and v2.\n\nPiperOrigin-RevId: 300276913\n\n309b899ca18a4c604bce63882a161d44854da549\nPublish `Backup` APIs and protos.\n\nPiperOrigin-RevId: 300246038\n\neced64c3f122421350b4aca68a28e89121d20db8\nadd PHP client libraries\n\nPiperOrigin-RevId: 300193634\n\n7727af0e39df1ae9ad715895c8576d7b65cf6c6d\nfeat: use the latest gapic-generator and protoc-java-resource-name-plugin in googleapis/WORKSPACE.\n\nPiperOrigin-RevId: 300188410\n\n2a25aa351dd5b5fe14895266aff5824d90ce757b\nBreaking change: remove the ProjectOrTenant resource and its references.\n\nPiperOrigin-RevId: 300182152\n\na499dbb28546379415f51803505cfb6123477e71\nUpdate web risk v1 gapic config and BUILD file.\n\nPiperOrigin-RevId: 300152177\n\n52701da10fec2a5f9796e8d12518c0fe574488fe\nFix: apply appropriate namespace/package options for C#, PHP and Ruby.\n\nPiperOrigin-RevId: 300123508\n\n365c029b8cdb63f7751b92ab490f1976e616105c\nAdd CC targets to the kms protos.\n\nThese are needed by go/tink.\n\nPiperOrigin-RevId: 300038469\n\n4ba9aa8a4a1413b88dca5a8fa931824ee9c284e6\nExpose logo recognition API proto for GA.\n\nPiperOrigin-RevId: 299971671\n\n1c9fc2c9e03dadf15f16b1c4f570955bdcebe00e\nAdding ruby_package option to accessapproval.proto for the Ruby client libraries generation.\n\nPiperOrigin-RevId: 299955924\n\n1cc6f0a7bfb147e6f2ede911d9b01e7a9923b719\nbuild(google/maps/routes): generate api clients\n\nPiperOrigin-RevId: 299955905\n\n29a47c965aac79e3fe8e3314482ca0b5967680f0\nIncrease timeout to 1hr for method `dropRange` in bigtable/admin/v2, which is\nsynced with the timeout setting in gapic_yaml.\n\nPiperOrigin-RevId: 299917154\n\n8f631c4c70a60a9c7da3749511ee4ad432b62898\nbuild(google/maps/roads/v1op): move go to monorepo pattern\n\nPiperOrigin-RevId: 299885195\n\nd66816518844ebbf63504c9e8dfc7133921dd2cd\nbuild(google/maps/roads/v1op): Add bazel build files to generate clients.\n\nPiperOrigin-RevId: 299851148\n\naf7dff701fabe029672168649c62356cf1bb43d0\nAdd LogPlayerReports and LogImpressions to Playable Locations service\n\nPiperOrigin-RevId: 299724050\n\nb6927fca808f38df32a642c560082f5bf6538ced\nUpdate BigQuery Connection API v1beta1 proto: added credential to CloudSqlProperties.\n\nPiperOrigin-RevId: 299503150\n\n91e1fb5ef9829c0c7a64bfa5bde330e6ed594378\nchore: update protobuf (protoc) version to 3.11.2\n\nPiperOrigin-RevId: 299404145\n\n30e36b4bee6749c4799f4fc1a51cc8f058ba167d\nUpdate cloud asset api v1p4beta1.\n\nPiperOrigin-RevId: 299399890\n\nffbb493674099f265693872ae250711b2238090c\nfeat: cloudbuild/v1 add new fields and annotate OUTPUT_OUT fields.\n\nPiperOrigin-RevId: 299397780\n\nbc973a15818e00c19e121959832676e9b7607456\nbazel: Fix broken common dependency\n\nPiperOrigin-RevId: 299397431\n\n71094a343e3b962e744aa49eb9338219537474e4\nchore: bigtable/admin/v2 publish retry config\n\nPiperOrigin-RevId: 299391875\n\n8f488efd7bda33885cb674ddd023b3678c40bd82\nfeat: Migrate logging to GAPIC v2; release new features.\n\nIMPORTANT: This is a breaking change for client libraries\nin all languages.\n\nCommitter: @lukesneeringer, @jskeet\nPiperOrigin-RevId: 299370279\n\n007605bf9ad3a1fd775014ebefbf7f1e6b31ee71\nUpdate API for bigqueryreservation v1beta1.\n- Adds flex capacity commitment plan to CapacityCommitment.\n- Adds methods for getting and updating BiReservations.\n- Adds methods for updating/splitting/merging CapacityCommitments.\n\nPiperOrigin-RevId: 299368059\n\nf0b581b5bdf803e45201ecdb3688b60e381628a8\nfix: recommendationengine/v1beta1 update some comments\n\nPiperOrigin-RevId: 299181282\n\n10e9a0a833dc85ff8f05b2c67ebe5ac785fe04ff\nbuild: add generated BUILD file for Routes Preferred API\n\nPiperOrigin-RevId: 299164808\n\n86738c956a8238d7c77f729be78b0ed887a6c913\npublish v1p1beta1: update with absolute address in comments\n\nPiperOrigin-RevId: 299152383\n\n73d9f2ad4591de45c2e1f352bc99d70cbd2a6d95\npublish v1: update with absolute address in comments\n\nPiperOrigin-RevId: 299147194\n\nd2158f24cb77b0b0ccfe68af784c6a628705e3c6\npublish v1beta2: update with absolute address in comments\n\nPiperOrigin-RevId: 299147086\n\n7fca61292c11b4cd5b352cee1a50bf88819dd63b\npublish v1p2beta1: update with absolute address in comments\n\nPiperOrigin-RevId: 299146903\n\n583b7321624736e2c490e328f4b1957335779295\npublish v1p3beta1: update with absolute address in comments\n\nPiperOrigin-RevId: 299146674\n\n638253bf86d1ce1c314108a089b7351440c2f0bf\nfix: add java_multiple_files option for automl text_sentiment.proto\n\nPiperOrigin-RevId: 298971070\n\n373d655703bf914fb8b0b1cc4071d772bac0e0d1\nUpdate Recs AI Beta public bazel file\n\nPiperOrigin-RevId: 298961623\n\ndcc5d00fc8a8d8b56f16194d7c682027b2c66a3b\nfix: add java_multiple_files option for automl classification.proto\n\nPiperOrigin-RevId: 298953301\n\na3f791827266f3496a6a5201d58adc4bb265c2a3\nchore: automl/v1 publish annotations and retry config\n\nPiperOrigin-RevId: 298942178\n\n01c681586d8d6dbd60155289b587aee678530bd9\nMark return_immediately in PullRequest deprecated.\n\nPiperOrigin-RevId: 298893281\n\nc9f5e9c4bfed54bbd09227e990e7bded5f90f31c\nRemove out of date documentation for predicate support on the Storage API\n\nPiperOrigin-RevId: 298883309\n\nfd5b3b8238d783b04692a113ffe07c0363f5de0f\ngenerate webrisk v1 proto\n\nPiperOrigin-RevId: 298847934\n\n541b1ded4abadcc38e8178680b0677f65594ea6f\nUpdate cloud asset api v1p4beta1.\n\nPiperOrigin-RevId: 298686266\n\nc0d171acecb4f5b0bfd2c4ca34fc54716574e300\n Updated to include the Notification v1 API.\n\nPiperOrigin-RevId: 298652775\n\n2346a9186c0bff2c9cc439f2459d558068637e05\nAdd Service Directory v1beta1 protos and configs\n\nPiperOrigin-RevId: 298625638\n\na78ed801b82a5c6d9c5368e24b1412212e541bb7\nPublishing v3 protos and configs.\n\nPiperOrigin-RevId: 298607357\n\n" } }, { diff --git a/tests/unit/gapic/v1/test_database_admin_client_v1.py b/tests/unit/gapic/v1/test_database_admin_client_v1.py index d828f8ae1c..dec787ae89 100644 --- a/tests/unit/gapic/v1/test_database_admin_client_v1.py +++ b/tests/unit/gapic/v1/test_database_admin_client_v1.py @@ -22,11 +22,13 @@ from google.rpc import status_pb2 from google.cloud import spanner_admin_database_v1 +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.iam.v1 import iam_policy_pb2 from google.iam.v1 import policy_pb2 from google.longrunning import operations_pb2 from google.protobuf import empty_pb2 +from google.protobuf import field_mask_pb2 class MultiCallableStub(object): @@ -412,6 +414,386 @@ def test_test_iam_permissions_exception(self): with pytest.raises(CustomException): client.test_iam_permissions(resource, permissions) + def test_create_backup(self): + # Setup Expected Response + database = "database1789464955" + name = "name3373707" + size_bytes = 1796325715 + expected_response = { + "database": database, + "name": name, + "size_bytes": size_bytes, + } + expected_response = backup_pb2.Backup(**expected_response) + operation = operations_pb2.Operation( + name="operations/test_create_backup", done=True + ) + operation.response.Pack(expected_response) + + # Mock the API response + channel = ChannelStub(responses=[operation]) + patch = mock.patch("google.api_core.grpc_helpers.create_channel") + with patch as create_channel: + create_channel.return_value = channel + client = spanner_admin_database_v1.DatabaseAdminClient() + + # Setup Request + parent = client.instance_path("[PROJECT]", "[INSTANCE]") + backup_id = "backupId1355353272" + backup = {} + + response = client.create_backup(parent, backup_id, backup) + result = response.result() + assert expected_response == result + + assert len(channel.requests) == 1 + expected_request = backup_pb2.CreateBackupRequest( + parent=parent, backup_id=backup_id, backup=backup + ) + actual_request = channel.requests[0][1] + assert expected_request == actual_request + + def test_create_backup_exception(self): + # Setup Response + error = status_pb2.Status() + operation = operations_pb2.Operation( + name="operations/test_create_backup_exception", done=True + ) + operation.error.CopyFrom(error) + + # Mock the API response + channel = ChannelStub(responses=[operation]) + patch = mock.patch("google.api_core.grpc_helpers.create_channel") + with patch as create_channel: + create_channel.return_value = channel + client = spanner_admin_database_v1.DatabaseAdminClient() + + # Setup Request + parent = client.instance_path("[PROJECT]", "[INSTANCE]") + backup_id = "backupId1355353272" + backup = {} + + response = client.create_backup(parent, backup_id, backup) + exception = response.exception() + assert exception.errors[0] == error + + def test_get_backup(self): + # Setup Expected Response + database = "database1789464955" + name_2 = "name2-1052831874" + size_bytes = 1796325715 + expected_response = { + "database": database, + "name": name_2, + "size_bytes": size_bytes, + } + expected_response = backup_pb2.Backup(**expected_response) + + # Mock the API response + channel = ChannelStub(responses=[expected_response]) + patch = mock.patch("google.api_core.grpc_helpers.create_channel") + with patch as create_channel: + create_channel.return_value = channel + client = spanner_admin_database_v1.DatabaseAdminClient() + + # Setup Request + name = client.backup_path("[PROJECT]", "[INSTANCE]", "[BACKUP]") + + response = client.get_backup(name) + assert expected_response == response + + assert len(channel.requests) == 1 + expected_request = backup_pb2.GetBackupRequest(name=name) + actual_request = channel.requests[0][1] + assert expected_request == actual_request + + def test_get_backup_exception(self): + # Mock the API response + channel = ChannelStub(responses=[CustomException()]) + patch = mock.patch("google.api_core.grpc_helpers.create_channel") + with patch as create_channel: + create_channel.return_value = channel + client = spanner_admin_database_v1.DatabaseAdminClient() + + # Setup request + name = client.backup_path("[PROJECT]", "[INSTANCE]", "[BACKUP]") + + with pytest.raises(CustomException): + client.get_backup(name) + + def test_update_backup(self): + # Setup Expected Response + database = "database1789464955" + name = "name3373707" + size_bytes = 1796325715 + expected_response = { + "database": database, + "name": name, + "size_bytes": size_bytes, + } + expected_response = backup_pb2.Backup(**expected_response) + + # Mock the API response + channel = ChannelStub(responses=[expected_response]) + patch = mock.patch("google.api_core.grpc_helpers.create_channel") + with patch as create_channel: + create_channel.return_value = channel + client = spanner_admin_database_v1.DatabaseAdminClient() + + # Setup Request + backup = {} + update_mask = {} + + response = client.update_backup(backup, update_mask) + assert expected_response == response + + assert len(channel.requests) == 1 + expected_request = backup_pb2.UpdateBackupRequest( + backup=backup, update_mask=update_mask + ) + actual_request = channel.requests[0][1] + assert expected_request == actual_request + + def test_update_backup_exception(self): + # Mock the API response + channel = ChannelStub(responses=[CustomException()]) + patch = mock.patch("google.api_core.grpc_helpers.create_channel") + with patch as create_channel: + create_channel.return_value = channel + client = spanner_admin_database_v1.DatabaseAdminClient() + + # Setup request + backup = {} + update_mask = {} + + with pytest.raises(CustomException): + client.update_backup(backup, update_mask) + + def test_delete_backup(self): + channel = ChannelStub() + patch = mock.patch("google.api_core.grpc_helpers.create_channel") + with patch as create_channel: + create_channel.return_value = channel + client = spanner_admin_database_v1.DatabaseAdminClient() + + # Setup Request + name = client.backup_path("[PROJECT]", "[INSTANCE]", "[BACKUP]") + + client.delete_backup(name) + + assert len(channel.requests) == 1 + expected_request = backup_pb2.DeleteBackupRequest(name=name) + actual_request = channel.requests[0][1] + assert expected_request == actual_request + + def test_delete_backup_exception(self): + # Mock the API response + channel = ChannelStub(responses=[CustomException()]) + patch = mock.patch("google.api_core.grpc_helpers.create_channel") + with patch as create_channel: + create_channel.return_value = channel + client = spanner_admin_database_v1.DatabaseAdminClient() + + # Setup request + name = client.backup_path("[PROJECT]", "[INSTANCE]", "[BACKUP]") + + with pytest.raises(CustomException): + client.delete_backup(name) + + def test_list_backups(self): + # Setup Expected Response + next_page_token = "" + backups_element = {} + backups = [backups_element] + expected_response = {"next_page_token": next_page_token, "backups": backups} + expected_response = backup_pb2.ListBackupsResponse(**expected_response) + + # Mock the API response + channel = ChannelStub(responses=[expected_response]) + patch = mock.patch("google.api_core.grpc_helpers.create_channel") + with patch as create_channel: + create_channel.return_value = channel + client = spanner_admin_database_v1.DatabaseAdminClient() + + # Setup Request + parent = client.instance_path("[PROJECT]", "[INSTANCE]") + + paged_list_response = client.list_backups(parent) + resources = list(paged_list_response) + assert len(resources) == 1 + + assert expected_response.backups[0] == resources[0] + + assert len(channel.requests) == 1 + expected_request = backup_pb2.ListBackupsRequest(parent=parent) + actual_request = channel.requests[0][1] + assert expected_request == actual_request + + def test_list_backups_exception(self): + channel = ChannelStub(responses=[CustomException()]) + patch = mock.patch("google.api_core.grpc_helpers.create_channel") + with patch as create_channel: + create_channel.return_value = channel + client = spanner_admin_database_v1.DatabaseAdminClient() + + # Setup request + parent = client.instance_path("[PROJECT]", "[INSTANCE]") + + paged_list_response = client.list_backups(parent) + with pytest.raises(CustomException): + list(paged_list_response) + + def test_restore_database(self): + # Setup Expected Response + name = "name3373707" + expected_response = {"name": name} + expected_response = spanner_database_admin_pb2.Database(**expected_response) + operation = operations_pb2.Operation( + name="operations/test_restore_database", done=True + ) + operation.response.Pack(expected_response) + + # Mock the API response + channel = ChannelStub(responses=[operation]) + patch = mock.patch("google.api_core.grpc_helpers.create_channel") + with patch as create_channel: + create_channel.return_value = channel + client = spanner_admin_database_v1.DatabaseAdminClient() + + # Setup Request + parent = client.instance_path("[PROJECT]", "[INSTANCE]") + database_id = "databaseId816491103" + + response = client.restore_database(parent, database_id) + result = response.result() + assert expected_response == result + + assert len(channel.requests) == 1 + expected_request = spanner_database_admin_pb2.RestoreDatabaseRequest( + parent=parent, database_id=database_id + ) + actual_request = channel.requests[0][1] + assert expected_request == actual_request + + def test_restore_database_exception(self): + # Setup Response + error = status_pb2.Status() + operation = operations_pb2.Operation( + name="operations/test_restore_database_exception", done=True + ) + operation.error.CopyFrom(error) + + # Mock the API response + channel = ChannelStub(responses=[operation]) + patch = mock.patch("google.api_core.grpc_helpers.create_channel") + with patch as create_channel: + create_channel.return_value = channel + client = spanner_admin_database_v1.DatabaseAdminClient() + + # Setup Request + parent = client.instance_path("[PROJECT]", "[INSTANCE]") + database_id = "databaseId816491103" + + response = client.restore_database(parent, database_id) + exception = response.exception() + assert exception.errors[0] == error + + def test_list_database_operations(self): + # Setup Expected Response + next_page_token = "" + operations_element = {} + operations = [operations_element] + expected_response = { + "next_page_token": next_page_token, + "operations": operations, + } + expected_response = spanner_database_admin_pb2.ListDatabaseOperationsResponse( + **expected_response + ) + + # Mock the API response + channel = ChannelStub(responses=[expected_response]) + patch = mock.patch("google.api_core.grpc_helpers.create_channel") + with patch as create_channel: + create_channel.return_value = channel + client = spanner_admin_database_v1.DatabaseAdminClient() + + # Setup Request + parent = client.instance_path("[PROJECT]", "[INSTANCE]") + + paged_list_response = client.list_database_operations(parent) + resources = list(paged_list_response) + assert len(resources) == 1 + + assert expected_response.operations[0] == resources[0] + + assert len(channel.requests) == 1 + expected_request = spanner_database_admin_pb2.ListDatabaseOperationsRequest( + parent=parent + ) + actual_request = channel.requests[0][1] + assert expected_request == actual_request + + def test_list_database_operations_exception(self): + channel = ChannelStub(responses=[CustomException()]) + patch = mock.patch("google.api_core.grpc_helpers.create_channel") + with patch as create_channel: + create_channel.return_value = channel + client = spanner_admin_database_v1.DatabaseAdminClient() + + # Setup request + parent = client.instance_path("[PROJECT]", "[INSTANCE]") + + paged_list_response = client.list_database_operations(parent) + with pytest.raises(CustomException): + list(paged_list_response) + + def test_list_backup_operations(self): + # Setup Expected Response + next_page_token = "" + operations_element = {} + operations = [operations_element] + expected_response = { + "next_page_token": next_page_token, + "operations": operations, + } + expected_response = backup_pb2.ListBackupOperationsResponse(**expected_response) + + # Mock the API response + channel = ChannelStub(responses=[expected_response]) + patch = mock.patch("google.api_core.grpc_helpers.create_channel") + with patch as create_channel: + create_channel.return_value = channel + client = spanner_admin_database_v1.DatabaseAdminClient() + + # Setup Request + parent = client.instance_path("[PROJECT]", "[INSTANCE]") + + paged_list_response = client.list_backup_operations(parent) + resources = list(paged_list_response) + assert len(resources) == 1 + + assert expected_response.operations[0] == resources[0] + + assert len(channel.requests) == 1 + expected_request = backup_pb2.ListBackupOperationsRequest(parent=parent) + actual_request = channel.requests[0][1] + assert expected_request == actual_request + + def test_list_backup_operations_exception(self): + channel = ChannelStub(responses=[CustomException()]) + patch = mock.patch("google.api_core.grpc_helpers.create_channel") + with patch as create_channel: + create_channel.return_value = channel + client = spanner_admin_database_v1.DatabaseAdminClient() + + # Setup request + parent = client.instance_path("[PROJECT]", "[INSTANCE]") + + paged_list_response = client.list_backup_operations(parent) + with pytest.raises(CustomException): + list(paged_list_response) + def test_list_databases(self): # Setup Expected Response next_page_token = ""