@@ -232,6 +232,110 @@ def __init__(
232
232
self ._inner_api_calls = {}
233
233
234
234
# Service calls
235
+ def list_databases (
236
+ self ,
237
+ parent ,
238
+ page_size = None ,
239
+ retry = google .api_core .gapic_v1 .method .DEFAULT ,
240
+ timeout = google .api_core .gapic_v1 .method .DEFAULT ,
241
+ metadata = None ,
242
+ ):
243
+ """
244
+ Lists Cloud Spanner databases.
245
+
246
+ Example:
247
+ >>> from google.cloud import spanner_admin_database_v1
248
+ >>>
249
+ >>> client = spanner_admin_database_v1.DatabaseAdminClient()
250
+ >>>
251
+ >>> parent = client.instance_path('[PROJECT]', '[INSTANCE]')
252
+ >>>
253
+ >>> # Iterate over all results
254
+ >>> for element in client.list_databases(parent):
255
+ ... # process element
256
+ ... pass
257
+ >>>
258
+ >>>
259
+ >>> # Alternatively:
260
+ >>>
261
+ >>> # Iterate over results one page at a time
262
+ >>> for page in client.list_databases(parent).pages:
263
+ ... for element in page:
264
+ ... # process element
265
+ ... pass
266
+
267
+ Args:
268
+ parent (str): Required. The instance whose databases should be listed. Values are
269
+ of the form ``projects/<project>/instances/<instance>``.
270
+ page_size (int): The maximum number of resources contained in the
271
+ underlying API response. If page streaming is performed per-
272
+ resource, this parameter does not affect the return value. If page
273
+ streaming is performed per-page, this determines the maximum number
274
+ of resources in a page.
275
+ retry (Optional[google.api_core.retry.Retry]): A retry object used
276
+ to retry requests. If ``None`` is specified, requests will
277
+ be retried using a default configuration.
278
+ timeout (Optional[float]): The amount of time, in seconds, to wait
279
+ for the request to complete. Note that if ``retry`` is
280
+ specified, the timeout applies to each individual attempt.
281
+ metadata (Optional[Sequence[Tuple[str, str]]]): Additional metadata
282
+ that is provided to the method.
283
+
284
+ Returns:
285
+ A :class:`~google.api_core.page_iterator.PageIterator` instance.
286
+ An iterable of :class:`~google.cloud.spanner_admin_database_v1.types.Database` instances.
287
+ You can also iterate over the pages of the response
288
+ using its `pages` property.
289
+
290
+ Raises:
291
+ google.api_core.exceptions.GoogleAPICallError: If the request
292
+ failed for any reason.
293
+ google.api_core.exceptions.RetryError: If the request failed due
294
+ to a retryable error and retry attempts failed.
295
+ ValueError: If the parameters are invalid.
296
+ """
297
+ # Wrap the transport method to add retry and timeout logic.
298
+ if "list_databases" not in self ._inner_api_calls :
299
+ self ._inner_api_calls [
300
+ "list_databases"
301
+ ] = google .api_core .gapic_v1 .method .wrap_method (
302
+ self .transport .list_databases ,
303
+ default_retry = self ._method_configs ["ListDatabases" ].retry ,
304
+ default_timeout = self ._method_configs ["ListDatabases" ].timeout ,
305
+ client_info = self ._client_info ,
306
+ )
307
+
308
+ request = spanner_database_admin_pb2 .ListDatabasesRequest (
309
+ parent = parent , page_size = page_size
310
+ )
311
+ if metadata is None :
312
+ metadata = []
313
+ metadata = list (metadata )
314
+ try :
315
+ routing_header = [("parent" , parent )]
316
+ except AttributeError :
317
+ pass
318
+ else :
319
+ routing_metadata = google .api_core .gapic_v1 .routing_header .to_grpc_metadata (
320
+ routing_header
321
+ )
322
+ metadata .append (routing_metadata )
323
+
324
+ iterator = google .api_core .page_iterator .GRPCIterator (
325
+ client = None ,
326
+ method = functools .partial (
327
+ self ._inner_api_calls ["list_databases" ],
328
+ retry = retry ,
329
+ timeout = timeout ,
330
+ metadata = metadata ,
331
+ ),
332
+ request = request ,
333
+ items_field = "databases" ,
334
+ request_token_field = "page_token" ,
335
+ response_token_field = "next_page_token" ,
336
+ )
337
+ return iterator
338
+
235
339
def create_database (
236
340
self ,
237
341
parent ,
@@ -1817,107 +1921,3 @@ def list_backup_operations(
1817
1921
response_token_field = "next_page_token" ,
1818
1922
)
1819
1923
return iterator
1820
-
1821
- def list_databases (
1822
- self ,
1823
- parent ,
1824
- page_size = None ,
1825
- retry = google .api_core .gapic_v1 .method .DEFAULT ,
1826
- timeout = google .api_core .gapic_v1 .method .DEFAULT ,
1827
- metadata = None ,
1828
- ):
1829
- """
1830
- Lists Cloud Spanner databases.
1831
-
1832
- Example:
1833
- >>> from google.cloud import spanner_admin_database_v1
1834
- >>>
1835
- >>> client = spanner_admin_database_v1.DatabaseAdminClient()
1836
- >>>
1837
- >>> parent = client.instance_path('[PROJECT]', '[INSTANCE]')
1838
- >>>
1839
- >>> # Iterate over all results
1840
- >>> for element in client.list_databases(parent):
1841
- ... # process element
1842
- ... pass
1843
- >>>
1844
- >>>
1845
- >>> # Alternatively:
1846
- >>>
1847
- >>> # Iterate over results one page at a time
1848
- >>> for page in client.list_databases(parent).pages:
1849
- ... for element in page:
1850
- ... # process element
1851
- ... pass
1852
-
1853
- Args:
1854
- parent (str): Required. The instance whose databases should be listed. Values are
1855
- of the form ``projects/<project>/instances/<instance>``.
1856
- page_size (int): The maximum number of resources contained in the
1857
- underlying API response. If page streaming is performed per-
1858
- resource, this parameter does not affect the return value. If page
1859
- streaming is performed per-page, this determines the maximum number
1860
- of resources in a page.
1861
- retry (Optional[google.api_core.retry.Retry]): A retry object used
1862
- to retry requests. If ``None`` is specified, requests will
1863
- be retried using a default configuration.
1864
- timeout (Optional[float]): The amount of time, in seconds, to wait
1865
- for the request to complete. Note that if ``retry`` is
1866
- specified, the timeout applies to each individual attempt.
1867
- metadata (Optional[Sequence[Tuple[str, str]]]): Additional metadata
1868
- that is provided to the method.
1869
-
1870
- Returns:
1871
- A :class:`~google.api_core.page_iterator.PageIterator` instance.
1872
- An iterable of :class:`~google.cloud.spanner_admin_database_v1.types.Database` instances.
1873
- You can also iterate over the pages of the response
1874
- using its `pages` property.
1875
-
1876
- Raises:
1877
- google.api_core.exceptions.GoogleAPICallError: If the request
1878
- failed for any reason.
1879
- google.api_core.exceptions.RetryError: If the request failed due
1880
- to a retryable error and retry attempts failed.
1881
- ValueError: If the parameters are invalid.
1882
- """
1883
- # Wrap the transport method to add retry and timeout logic.
1884
- if "list_databases" not in self ._inner_api_calls :
1885
- self ._inner_api_calls [
1886
- "list_databases"
1887
- ] = google .api_core .gapic_v1 .method .wrap_method (
1888
- self .transport .list_databases ,
1889
- default_retry = self ._method_configs ["ListDatabases" ].retry ,
1890
- default_timeout = self ._method_configs ["ListDatabases" ].timeout ,
1891
- client_info = self ._client_info ,
1892
- )
1893
-
1894
- request = spanner_database_admin_pb2 .ListDatabasesRequest (
1895
- parent = parent , page_size = page_size
1896
- )
1897
- if metadata is None :
1898
- metadata = []
1899
- metadata = list (metadata )
1900
- try :
1901
- routing_header = [("parent" , parent )]
1902
- except AttributeError :
1903
- pass
1904
- else :
1905
- routing_metadata = google .api_core .gapic_v1 .routing_header .to_grpc_metadata (
1906
- routing_header
1907
- )
1908
- metadata .append (routing_metadata )
1909
-
1910
- iterator = google .api_core .page_iterator .GRPCIterator (
1911
- client = None ,
1912
- method = functools .partial (
1913
- self ._inner_api_calls ["list_databases" ],
1914
- retry = retry ,
1915
- timeout = timeout ,
1916
- metadata = metadata ,
1917
- ),
1918
- request = request ,
1919
- items_field = "databases" ,
1920
- request_token_field = "page_token" ,
1921
- response_token_field = "next_page_token" ,
1922
- )
1923
- return iterator
0 commit comments