@@ -88,7 +88,12 @@ def from_service_account_file(cls, filename, *args, **kwargs):
8888
8989 @classmethod
9090 def database_path (cls , project , instance , database ):
91- """Return a fully-qualified database string."""
91+ """DEPRECATED. Return a fully-qualified database string."""
92+ warnings .warn (
93+ "Resource name helper functions are deprecated." ,
94+ PendingDeprecationWarning ,
95+ stacklevel = 1 ,
96+ )
9297 return google .api_core .path_template .expand (
9398 "projects/{project}/instances/{instance}/databases/{database}" ,
9499 project = project ,
@@ -98,7 +103,12 @@ def database_path(cls, project, instance, database):
98103
99104 @classmethod
100105 def instance_path (cls , project , instance ):
101- """Return a fully-qualified instance string."""
106+ """DEPRECATED. Return a fully-qualified instance string."""
107+ warnings .warn (
108+ "Resource name helper functions are deprecated." ,
109+ PendingDeprecationWarning ,
110+ stacklevel = 1 ,
111+ )
102112 return google .api_core .path_template .expand (
103113 "projects/{project}/instances/{instance}" ,
104114 project = project ,
@@ -218,110 +228,6 @@ def __init__(
218228 self ._inner_api_calls = {}
219229
220230 # Service calls
221- def list_databases (
222- self ,
223- parent ,
224- page_size = None ,
225- retry = google .api_core .gapic_v1 .method .DEFAULT ,
226- timeout = google .api_core .gapic_v1 .method .DEFAULT ,
227- metadata = None ,
228- ):
229- """
230- Lists Cloud Spanner databases.
231-
232- Example:
233- >>> from google.cloud import spanner_admin_database_v1
234- >>>
235- >>> client = spanner_admin_database_v1.DatabaseAdminClient()
236- >>>
237- >>> parent = client.instance_path('[PROJECT]', '[INSTANCE]')
238- >>>
239- >>> # Iterate over all results
240- >>> for element in client.list_databases(parent):
241- ... # process element
242- ... pass
243- >>>
244- >>>
245- >>> # Alternatively:
246- >>>
247- >>> # Iterate over results one page at a time
248- >>> for page in client.list_databases(parent).pages:
249- ... for element in page:
250- ... # process element
251- ... pass
252-
253- Args:
254- parent (str): Required. The instance whose databases should be listed. Values are of
255- the form ``projects/<project>/instances/<instance>``.
256- page_size (int): The maximum number of resources contained in the
257- underlying API response. If page streaming is performed per-
258- resource, this parameter does not affect the return value. If page
259- streaming is performed per-page, this determines the maximum number
260- of resources in a page.
261- retry (Optional[google.api_core.retry.Retry]): A retry object used
262- to retry requests. If ``None`` is specified, requests will
263- be retried using a default configuration.
264- timeout (Optional[float]): The amount of time, in seconds, to wait
265- for the request to complete. Note that if ``retry`` is
266- specified, the timeout applies to each individual attempt.
267- metadata (Optional[Sequence[Tuple[str, str]]]): Additional metadata
268- that is provided to the method.
269-
270- Returns:
271- A :class:`~google.api_core.page_iterator.PageIterator` instance.
272- An iterable of :class:`~google.cloud.spanner_admin_database_v1.types.Database` instances.
273- You can also iterate over the pages of the response
274- using its `pages` property.
275-
276- Raises:
277- google.api_core.exceptions.GoogleAPICallError: If the request
278- failed for any reason.
279- google.api_core.exceptions.RetryError: If the request failed due
280- to a retryable error and retry attempts failed.
281- ValueError: If the parameters are invalid.
282- """
283- # Wrap the transport method to add retry and timeout logic.
284- if "list_databases" not in self ._inner_api_calls :
285- self ._inner_api_calls [
286- "list_databases"
287- ] = google .api_core .gapic_v1 .method .wrap_method (
288- self .transport .list_databases ,
289- default_retry = self ._method_configs ["ListDatabases" ].retry ,
290- default_timeout = self ._method_configs ["ListDatabases" ].timeout ,
291- client_info = self ._client_info ,
292- )
293-
294- request = spanner_database_admin_pb2 .ListDatabasesRequest (
295- parent = parent , page_size = page_size
296- )
297- if metadata is None :
298- metadata = []
299- metadata = list (metadata )
300- try :
301- routing_header = [("parent" , parent )]
302- except AttributeError :
303- pass
304- else :
305- routing_metadata = google .api_core .gapic_v1 .routing_header .to_grpc_metadata (
306- routing_header
307- )
308- metadata .append (routing_metadata )
309-
310- iterator = google .api_core .page_iterator .GRPCIterator (
311- client = None ,
312- method = functools .partial (
313- self ._inner_api_calls ["list_databases" ],
314- retry = retry ,
315- timeout = timeout ,
316- metadata = metadata ,
317- ),
318- request = request ,
319- items_field = "databases" ,
320- request_token_field = "page_token" ,
321- response_token_field = "next_page_token" ,
322- )
323- return iterator
324-
325231 def create_database (
326232 self ,
327233 parent ,
@@ -769,7 +675,8 @@ def set_iam_policy(
769675 >>>
770676 >>> client = spanner_admin_database_v1.DatabaseAdminClient()
771677 >>>
772- >>> resource = client.database_path('[PROJECT]', '[INSTANCE]', '[DATABASE]')
678+ >>> # TODO: Initialize `resource`:
679+ >>> resource = ''
773680 >>>
774681 >>> # TODO: Initialize `policy`:
775682 >>> policy = {}
@@ -854,7 +761,8 @@ def get_iam_policy(
854761 >>>
855762 >>> client = spanner_admin_database_v1.DatabaseAdminClient()
856763 >>>
857- >>> resource = client.database_path('[PROJECT]', '[INSTANCE]', '[DATABASE]')
764+ >>> # TODO: Initialize `resource`:
765+ >>> resource = ''
858766 >>>
859767 >>> response = client.get_iam_policy(resource)
860768
@@ -938,7 +846,8 @@ def test_iam_permissions(
938846 >>>
939847 >>> client = spanner_admin_database_v1.DatabaseAdminClient()
940848 >>>
941- >>> resource = client.database_path('[PROJECT]', '[INSTANCE]', '[DATABASE]')
849+ >>> # TODO: Initialize `resource`:
850+ >>> resource = ''
942851 >>>
943852 >>> # TODO: Initialize `permissions`:
944853 >>> permissions = []
@@ -1001,3 +910,107 @@ def test_iam_permissions(
1001910 return self ._inner_api_calls ["test_iam_permissions" ](
1002911 request , retry = retry , timeout = timeout , metadata = metadata
1003912 )
913+
914+ def list_databases (
915+ self ,
916+ parent ,
917+ page_size = None ,
918+ retry = google .api_core .gapic_v1 .method .DEFAULT ,
919+ timeout = google .api_core .gapic_v1 .method .DEFAULT ,
920+ metadata = None ,
921+ ):
922+ """
923+ Lists Cloud Spanner databases.
924+
925+ Example:
926+ >>> from google.cloud import spanner_admin_database_v1
927+ >>>
928+ >>> client = spanner_admin_database_v1.DatabaseAdminClient()
929+ >>>
930+ >>> parent = client.instance_path('[PROJECT]', '[INSTANCE]')
931+ >>>
932+ >>> # Iterate over all results
933+ >>> for element in client.list_databases(parent):
934+ ... # process element
935+ ... pass
936+ >>>
937+ >>>
938+ >>> # Alternatively:
939+ >>>
940+ >>> # Iterate over results one page at a time
941+ >>> for page in client.list_databases(parent).pages:
942+ ... for element in page:
943+ ... # process element
944+ ... pass
945+
946+ Args:
947+ parent (str): Required. The instance whose databases should be listed. Values are of
948+ the form ``projects/<project>/instances/<instance>``.
949+ page_size (int): The maximum number of resources contained in the
950+ underlying API response. If page streaming is performed per-
951+ resource, this parameter does not affect the return value. If page
952+ streaming is performed per-page, this determines the maximum number
953+ of resources in a page.
954+ retry (Optional[google.api_core.retry.Retry]): A retry object used
955+ to retry requests. If ``None`` is specified, requests will
956+ be retried using a default configuration.
957+ timeout (Optional[float]): The amount of time, in seconds, to wait
958+ for the request to complete. Note that if ``retry`` is
959+ specified, the timeout applies to each individual attempt.
960+ metadata (Optional[Sequence[Tuple[str, str]]]): Additional metadata
961+ that is provided to the method.
962+
963+ Returns:
964+ A :class:`~google.api_core.page_iterator.PageIterator` instance.
965+ An iterable of :class:`~google.cloud.spanner_admin_database_v1.types.Database` instances.
966+ You can also iterate over the pages of the response
967+ using its `pages` property.
968+
969+ Raises:
970+ google.api_core.exceptions.GoogleAPICallError: If the request
971+ failed for any reason.
972+ google.api_core.exceptions.RetryError: If the request failed due
973+ to a retryable error and retry attempts failed.
974+ ValueError: If the parameters are invalid.
975+ """
976+ # Wrap the transport method to add retry and timeout logic.
977+ if "list_databases" not in self ._inner_api_calls :
978+ self ._inner_api_calls [
979+ "list_databases"
980+ ] = google .api_core .gapic_v1 .method .wrap_method (
981+ self .transport .list_databases ,
982+ default_retry = self ._method_configs ["ListDatabases" ].retry ,
983+ default_timeout = self ._method_configs ["ListDatabases" ].timeout ,
984+ client_info = self ._client_info ,
985+ )
986+
987+ request = spanner_database_admin_pb2 .ListDatabasesRequest (
988+ parent = parent , page_size = page_size
989+ )
990+ if metadata is None :
991+ metadata = []
992+ metadata = list (metadata )
993+ try :
994+ routing_header = [("parent" , parent )]
995+ except AttributeError :
996+ pass
997+ else :
998+ routing_metadata = google .api_core .gapic_v1 .routing_header .to_grpc_metadata (
999+ routing_header
1000+ )
1001+ metadata .append (routing_metadata )
1002+
1003+ iterator = google .api_core .page_iterator .GRPCIterator (
1004+ client = None ,
1005+ method = functools .partial (
1006+ self ._inner_api_calls ["list_databases" ],
1007+ retry = retry ,
1008+ timeout = timeout ,
1009+ metadata = metadata ,
1010+ ),
1011+ request = request ,
1012+ items_field = "databases" ,
1013+ request_token_field = "page_token" ,
1014+ response_token_field = "next_page_token" ,
1015+ )
1016+ return iterator
0 commit comments