Thanks to visit codestin.com
Credit goes to github.com

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

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 2 additions & 17 deletions google/cloud/spanner_v1/instance.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@

"""User friendly container for Cloud Spanner Instance."""

import google.api_core.operation
import re

from google.cloud.spanner_admin_instance_v1 import Instance as InstancePB
Expand Down Expand Up @@ -466,7 +465,7 @@ def list_backup_operations(self, filter_="", page_size=None):
page_iter = self._client.database_admin_api.list_backup_operations(
request=request, metadata=metadata
)
return map(self._item_to_operation, page_iter)
return page_iter

def list_database_operations(self, filter_="", page_size=None):
"""List database operations for the instance.
Expand Down Expand Up @@ -494,18 +493,4 @@ def list_database_operations(self, filter_="", page_size=None):
page_iter = self._client.database_admin_api.list_database_operations(
request=request, metadata=metadata
)
return map(self._item_to_operation, page_iter)

def _item_to_operation(self, operation_pb):
"""Convert an operation protobuf to the native object.
:type operation_pb: :class:`~google.longrunning.operations.Operation`
:param operation_pb: An operation returned from the API.
:rtype: :class:`~google.api_core.operation.Operation`
:returns: The next operation in the page.
"""
operations_client = self._client.database_admin_api.transport.operations_client
metadata_type = _type_string_to_type_pb(operation_pb.metadata.type_url)
response_type = _OPERATION_RESPONSE_TYPES[metadata_type]
return google.api_core.operation.from_gapic(
operation_pb, operations_client, response_type, metadata_type=metadata_type
)
return page_iter
6 changes: 6 additions & 0 deletions samples/samples/backup_sample_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,12 @@ def test_restore_database(capsys):
assert BACKUP_ID in out


@pytest.mark.skip(
reason=(
"failing due to a production bug"
"https://github.com/googleapis/python-spanner/issues/149"
)
)
def test_list_backup_operations(capsys, spanner_instance):
backup_sample.list_backup_operations(INSTANCE_ID, DATABASE_ID)
out, _ = capsys.readouterr()
Expand Down