Skip to content

Commit c566550

Browse files
dpebottseaver
authored andcommitted
Fix client_info bug, update docstrings. (googleapis#6420)
1 parent 20a4b5d commit c566550

7 files changed

Lines changed: 561 additions & 575 deletions

File tree

spanner/google/cloud/spanner_admin_database_v1/gapic/database_admin_client.py

Lines changed: 53 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -169,9 +169,10 @@ def __init__(self,
169169
)
170170

171171
if client_info is None:
172-
client_info = (
173-
google.api_core.gapic_v1.client_info.DEFAULT_CLIENT_INFO)
174-
client_info.gapic_version = _GAPIC_LIBRARY_VERSION
172+
client_info = google.api_core.gapic_v1.client_info.ClientInfo(
173+
gapic_version=_GAPIC_LIBRARY_VERSION, )
174+
else:
175+
client_info.gapic_version = _GAPIC_LIBRARY_VERSION
175176
self._client_info = client_info
176177

177178
# Parse out the default settings for retry and timeout for each RPC
@@ -213,14 +214,14 @@ def list_databases(self,
213214
>>> # Alternatively:
214215
>>>
215216
>>> # Iterate over results one page at a time
216-
>>> for page in client.list_databases(parent, options=CallOptions(page_token=INITIAL_PAGE)):
217+
>>> for page in client.list_databases(parent).pages:
217218
... for element in page:
218219
... # process element
219220
... pass
220221
221222
Args:
222-
parent (str): Required. The instance whose databases should be listed.
223-
Values are of the form ``projects/<project>/instances/<instance>``.
223+
parent (str): Required. The instance whose databases should be listed. Values are of
224+
the form ``projects/<project>/instances/<instance>``.
224225
page_size (int): The maximum number of resources contained in the
225226
underlying API response. If page streaming is performed per-
226227
resource, this parameter does not affect the return value. If page
@@ -285,14 +286,12 @@ def create_database(self,
285286
timeout=google.api_core.gapic_v1.method.DEFAULT,
286287
metadata=None):
287288
"""
288-
Creates a new Cloud Spanner database and starts to prepare it for serving.
289-
The returned ``long-running operation`` will
290-
have a name of the format ``<database_name>/operations/<operation_id>`` and
291-
can be used to track preparation of the database. The
292-
``metadata`` field type is
293-
``CreateDatabaseMetadata``. The
294-
``response`` field type is
295-
``Database``, if successful.
289+
Creates a new Cloud Spanner database and starts to prepare it for
290+
serving. The returned ``long-running operation`` will have a name of the
291+
format ``<database_name>/operations/<operation_id>`` and can be used to
292+
track preparation of the database. The ``metadata`` field type is
293+
``CreateDatabaseMetadata``. The ``response`` field type is ``Database``,
294+
if successful.
296295
297296
Example:
298297
>>> from google.cloud import spanner_admin_database_v1
@@ -301,7 +300,7 @@ def create_database(self,
301300
>>>
302301
>>> parent = client.instance_path('[PROJECT]', '[INSTANCE]')
303302
>>>
304-
>>> # TODO: Initialize ``create_statement``:
303+
>>> # TODO: Initialize `create_statement`:
305304
>>> create_statement = ''
306305
>>>
307306
>>> response = client.create_database(parent, create_statement)
@@ -319,10 +318,10 @@ def create_database(self,
319318
parent (str): Required. The name of the instance that will serve the new database.
320319
Values are of the form ``projects/<project>/instances/<instance>``.
321320
create_statement (str): Required. A ``CREATE DATABASE`` statement, which specifies the ID of the
322-
new database. The database ID must conform to the regular expression
323-
``[a-z][a-z0-9_\-]*[a-z0-9]`` and be between 2 and 30 characters in length.
324-
If the database ID is a reserved word or if it contains a hyphen, the
325-
database ID must be enclosed in backticks.
321+
new database. The database ID must conform to the regular expression
322+
``[a-z][a-z0-9_\-]*[a-z0-9]`` and be between 2 and 30 characters in
323+
length. If the database ID is a reserved word or if it contains a
324+
hyphen, the database ID must be enclosed in backticks (`````).
326325
extra_statements (list[str]): An optional list of DDL statements to run inside the newly created
327326
database. Statements can create tables, indexes, etc. These
328327
statements execute atomically with the creation of the database:
@@ -435,11 +434,10 @@ def update_database_ddl(self,
435434
"""
436435
Updates the schema of a Cloud Spanner database by
437436
creating/altering/dropping tables, columns, indexes, etc. The returned
438-
``long-running operation`` will have a name of
439-
the format ``<database_name>/operations/<operation_id>`` and can be used to
440-
track execution of the schema change(s). The
441-
``metadata`` field type is
442-
``UpdateDatabaseDdlMetadata``. The operation has no response.
437+
``long-running operation`` will have a name of the format
438+
``<database_name>/operations/<operation_id>`` and can be used to track
439+
execution of the schema change(s). The ``metadata`` field type is
440+
``UpdateDatabaseDdlMetadata``. The operation has no response.
443441
444442
Example:
445443
>>> from google.cloud import spanner_admin_database_v1
@@ -448,7 +446,7 @@ def update_database_ddl(self,
448446
>>>
449447
>>> database = client.database_path('[PROJECT]', '[INSTANCE]', '[DATABASE]')
450448
>>>
451-
>>> # TODO: Initialize ``statements``:
449+
>>> # TODO: Initialize `statements`:
452450
>>> statements = []
453451
>>>
454452
>>> response = client.update_database_ddl(database, statements)
@@ -465,25 +463,21 @@ def update_database_ddl(self,
465463
Args:
466464
database (str): Required. The database to update.
467465
statements (list[str]): DDL statements to be applied to the database.
468-
operation_id (str): If empty, the new update request is assigned an
469-
automatically-generated operation ID. Otherwise, ``operation_id``
470-
is used to construct the name of the resulting
471-
``Operation``.
472-
473-
Specifying an explicit operation ID simplifies determining
474-
whether the statements were executed in the event that the
475-
``UpdateDatabaseDdl`` call is replayed,
476-
or the return value is otherwise lost: the ``database`` and
477-
``operation_id`` fields can be combined to form the
478-
``name`` of the resulting
479-
``longrunning.Operation``: ``<database>/operations/<operation_id>``.
480-
481-
``operation_id`` should be unique within the database, and must be
482-
a valid identifier: ``[a-z][a-z0-9_]*``. Note that
483-
automatically-generated operation IDs always begin with an
484-
underscore. If the named operation already exists,
485-
``UpdateDatabaseDdl`` returns
486-
``ALREADY_EXISTS``.
466+
operation_id (str): If empty, the new update request is assigned an automatically-generated
467+
operation ID. Otherwise, ``operation_id`` is used to construct the name
468+
of the resulting ``Operation``.
469+
470+
Specifying an explicit operation ID simplifies determining whether the
471+
statements were executed in the event that the ``UpdateDatabaseDdl``
472+
call is replayed, or the return value is otherwise lost: the
473+
``database`` and ``operation_id`` fields can be combined to form the
474+
``name`` of the resulting ``longrunning.Operation``:
475+
``<database>/operations/<operation_id>``.
476+
477+
``operation_id`` should be unique within the database, and must be a
478+
valid identifier: ``[a-z][a-z0-9_]*``. Note that automatically-generated
479+
operation IDs always begin with an underscore. If the named operation
480+
already exists, ``UpdateDatabaseDdl`` returns ``ALREADY_EXISTS``.
487481
retry (Optional[google.api_core.retry.Retry]): A retry object used
488482
to retry requests. If ``None`` is specified, requests will not
489483
be retried.
@@ -587,8 +581,8 @@ def get_database_ddl(self,
587581
metadata=None):
588582
"""
589583
Returns the schema of a Cloud Spanner database as a list of formatted
590-
DDL statements. This method does not show pending schema updates, those may
591-
be queried using the ``Operations`` API.
584+
DDL statements. This method does not show pending schema updates, those
585+
may be queried using the ``Operations`` API.
592586
593587
Example:
594588
>>> from google.cloud import spanner_admin_database_v1
@@ -656,7 +650,7 @@ def set_iam_policy(self,
656650
>>>
657651
>>> resource = client.database_path('[PROJECT]', '[INSTANCE]', '[DATABASE]')
658652
>>>
659-
>>> # TODO: Initialize ``policy``:
653+
>>> # TODO: Initialize `policy`:
660654
>>> policy = {}
661655
>>>
662656
>>> response = client.set_iam_policy(resource, policy)
@@ -665,10 +659,11 @@ def set_iam_policy(self,
665659
resource (str): REQUIRED: The resource for which the policy is being specified.
666660
``resource`` is usually specified as a path. For example, a Project
667661
resource is specified as ``projects/{project}``.
668-
policy (Union[dict, ~google.cloud.spanner_admin_database_v1.types.Policy]): REQUIRED: The complete policy to be applied to the ``resource``. The size of
669-
the policy is limited to a few 10s of KB. An empty policy is a
662+
policy (Union[dict, ~google.cloud.spanner_admin_database_v1.types.Policy]): REQUIRED: The complete policy to be applied to the ``resource``. The
663+
size of the policy is limited to a few 10s of KB. An empty policy is a
670664
valid policy but certain Cloud Platform services (such as Projects)
671665
might reject them.
666+
672667
If a dict is provided, it must be of the same form as the protobuf
673668
message :class:`~google.cloud.spanner_admin_database_v1.types.Policy`
674669
retry (Optional[google.api_core.retry.Retry]): A retry object used
@@ -774,12 +769,13 @@ def test_iam_permissions(self,
774769
timeout=google.api_core.gapic_v1.method.DEFAULT,
775770
metadata=None):
776771
"""
777-
Returns permissions that the caller has on the specified database resource.
772+
Returns permissions that the caller has on the specified database
773+
resource.
778774
779-
Attempting this RPC on a non-existent Cloud Spanner database will result in
780-
a NOT_FOUND error if the user has ``spanner.databases.list`` permission on
781-
the containing Cloud Spanner instance. Otherwise returns an empty set of
782-
permissions.
775+
Attempting this RPC on a non-existent Cloud Spanner database will result
776+
in a NOT\_FOUND error if the user has ``spanner.databases.list``
777+
permission on the containing Cloud Spanner instance. Otherwise returns
778+
an empty set of permissions.
783779
784780
Example:
785781
>>> from google.cloud import spanner_admin_database_v1
@@ -788,7 +784,7 @@ def test_iam_permissions(self,
788784
>>>
789785
>>> resource = client.database_path('[PROJECT]', '[INSTANCE]', '[DATABASE]')
790786
>>>
791-
>>> # TODO: Initialize ``permissions``:
787+
>>> # TODO: Initialize `permissions`:
792788
>>> permissions = []
793789
>>>
794790
>>> response = client.test_iam_permissions(resource, permissions)
@@ -799,8 +795,8 @@ def test_iam_permissions(self,
799795
resource is specified as ``projects/{project}``.
800796
permissions (list[str]): The set of permissions to check for the ``resource``. Permissions with
801797
wildcards (such as '*' or 'storage.*') are not allowed. For more
802-
information see
803-
`IAM Overview <https://cloud.google.com/iam/docs/overview#permissions>`_.
798+
information see `IAM
799+
Overview <https://cloud.google.com/iam/docs/overview#permissions>`__.
804800
retry (Optional[google.api_core.retry.Retry]): A retry object used
805801
to retry requests. If ``None`` is specified, requests will not
806802
be retried.

spanner/google/cloud/spanner_admin_database_v1/gapic/transports/database_admin_grpc_transport.py

Lines changed: 18 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -119,14 +119,12 @@ def list_databases(self):
119119
def create_database(self):
120120
"""Return the gRPC stub for {$apiMethod.name}.
121121
122-
Creates a new Cloud Spanner database and starts to prepare it for serving.
123-
The returned ``long-running operation`` will
124-
have a name of the format ``<database_name>/operations/<operation_id>`` and
125-
can be used to track preparation of the database. The
126-
``metadata`` field type is
127-
``CreateDatabaseMetadata``. The
128-
``response`` field type is
129-
``Database``, if successful.
122+
Creates a new Cloud Spanner database and starts to prepare it for
123+
serving. The returned ``long-running operation`` will have a name of the
124+
format ``<database_name>/operations/<operation_id>`` and can be used to
125+
track preparation of the database. The ``metadata`` field type is
126+
``CreateDatabaseMetadata``. The ``response`` field type is ``Database``,
127+
if successful.
130128
131129
Returns:
132130
Callable: A callable which accepts the appropriate
@@ -154,11 +152,10 @@ def update_database_ddl(self):
154152
155153
Updates the schema of a Cloud Spanner database by
156154
creating/altering/dropping tables, columns, indexes, etc. The returned
157-
``long-running operation`` will have a name of
158-
the format ``<database_name>/operations/<operation_id>`` and can be used to
159-
track execution of the schema change(s). The
160-
``metadata`` field type is
161-
``UpdateDatabaseDdlMetadata``. The operation has no response.
155+
``long-running operation`` will have a name of the format
156+
``<database_name>/operations/<operation_id>`` and can be used to track
157+
execution of the schema change(s). The ``metadata`` field type is
158+
``UpdateDatabaseDdlMetadata``. The operation has no response.
162159
163160
Returns:
164161
Callable: A callable which accepts the appropriate
@@ -185,8 +182,8 @@ def get_database_ddl(self):
185182
"""Return the gRPC stub for {$apiMethod.name}.
186183
187184
Returns the schema of a Cloud Spanner database as a list of formatted
188-
DDL statements. This method does not show pending schema updates, those may
189-
be queried using the ``Operations`` API.
185+
DDL statements. This method does not show pending schema updates, those
186+
may be queried using the ``Operations`` API.
190187
191188
Returns:
192189
Callable: A callable which accepts the appropriate
@@ -233,12 +230,13 @@ def get_iam_policy(self):
233230
def test_iam_permissions(self):
234231
"""Return the gRPC stub for {$apiMethod.name}.
235232
236-
Returns permissions that the caller has on the specified database resource.
233+
Returns permissions that the caller has on the specified database
234+
resource.
237235
238-
Attempting this RPC on a non-existent Cloud Spanner database will result in
239-
a NOT_FOUND error if the user has ``spanner.databases.list`` permission on
240-
the containing Cloud Spanner instance. Otherwise returns an empty set of
241-
permissions.
236+
Attempting this RPC on a non-existent Cloud Spanner database will result
237+
in a NOT\_FOUND error if the user has ``spanner.databases.list``
238+
permission on the containing Cloud Spanner instance. Otherwise returns
239+
an empty set of permissions.
242240
243241
Returns:
244242
Callable: A callable which accepts the appropriate

0 commit comments

Comments
 (0)