Skip to content

Commit af3df9c

Browse files
sangramqlsduskis
authored andcommitted
Bigtable client snippets (googleapis#7020)
* add conditional row snippets * add snippets * Add client snippets
1 parent c2fbf09 commit af3df9c

2 files changed

Lines changed: 69 additions & 0 deletions

File tree

bigtable/docs/snippets.py

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -425,5 +425,50 @@ def test_bigtable_set_iam_policy_then_get_iam_policy():
425425
assert len(policy.bigtable_admins) > 0
426426

427427

428+
def test_bigtable_project_path():
429+
import re
430+
# [START bigtable_project_path]
431+
from google.cloud.bigtable import Client
432+
433+
client = Client(admin=True)
434+
project_path = client.project_path
435+
# [END bigtable_project_path]
436+
437+
_project_path_re = re.compile(r'^projects/'
438+
r'(?P<project_id>'
439+
r'[_a-zA-Z0-9][-_.a-zA-Z0-9]*)$')
440+
assert _project_path_re.match(project_path)
441+
442+
443+
def test_bigtable_table_data_client():
444+
# [START bigtable_table_data_client]
445+
from google.cloud.bigtable import Client
446+
447+
client = Client(admin=True)
448+
table_data_client = client.table_data_client
449+
# [END bigtable_table_data_client]
450+
assert "BigtableClient" in str(table_data_client)
451+
452+
453+
def test_bigtable_table_admin_client():
454+
# [START bigtable_table_admin_client]
455+
from google.cloud.bigtable import Client
456+
457+
client = Client(admin=True)
458+
table_admin_client = client.table_admin_client
459+
# [END bigtable_table_admin_client]
460+
assert "BigtableTableAdmin" in str(table_admin_client)
461+
462+
463+
def test_bigtable_instance_admin_client():
464+
# [START bigtable_instance_admin_client]
465+
from google.cloud.bigtable import Client
466+
467+
client = Client(admin=True)
468+
instance_admin_client = client.instance_admin_client
469+
# [END bigtable_instance_admin_client]
470+
assert "BigtableInstanceAdmin" in str(instance_admin_client)
471+
472+
428473
if __name__ == "__main__":
429474
pytest.main()

bigtable/google/cloud/bigtable/client.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,12 @@ def project_path(self):
168168
This property will not change if ``project`` does not, but the
169169
return value is not cached.
170170
171+
For example:
172+
173+
.. literalinclude:: snippets.py
174+
:start-after: [START bigtable_project_path]
175+
:end-before: [END bigtable_project_path]
176+
171177
The project name is of the form
172178
173179
``"projects/{project}"``
@@ -181,6 +187,12 @@ def project_path(self):
181187
def table_data_client(self):
182188
"""Getter for the gRPC stub used for the Table Admin API.
183189
190+
For example:
191+
192+
.. literalinclude:: snippets.py
193+
:start-after: [START bigtable_table_data_client]
194+
:end-before: [END bigtable_table_data_client]
195+
184196
:rtype: :class:`.bigtable_v2.BigtableClient`
185197
:returns: A BigtableClient object.
186198
"""
@@ -194,6 +206,12 @@ def table_data_client(self):
194206
def table_admin_client(self):
195207
"""Getter for the gRPC stub used for the Table Admin API.
196208
209+
For example:
210+
211+
.. literalinclude:: snippets.py
212+
:start-after: [START bigtable_table_admin_client]
213+
:end-before: [END bigtable_table_admin_client]
214+
197215
:rtype: :class:`.bigtable_admin_pb2.BigtableTableAdmin`
198216
:returns: A BigtableTableAdmin instance.
199217
:raises: :class:`ValueError <exceptions.ValueError>` if the current
@@ -212,6 +230,12 @@ def table_admin_client(self):
212230
def instance_admin_client(self):
213231
"""Getter for the gRPC stub used for the Table Admin API.
214232
233+
For example:
234+
235+
.. literalinclude:: snippets.py
236+
:start-after: [START bigtable_instance_admin_client]
237+
:end-before: [END bigtable_instance_admin_client]
238+
215239
:rtype: :class:`.bigtable_admin_pb2.BigtableInstanceAdmin`
216240
:returns: A BigtableInstanceAdmin instance.
217241
:raises: :class:`ValueError <exceptions.ValueError>` if the current

0 commit comments

Comments
 (0)