Skip to content
This repository was archived by the owner on Aug 30, 2026. It is now read-only.

Commit 3ecca7a

Browse files
authored
docs: Pysamples new readme gen (#112)
This PR adds some new generation code to the synth.py to handle generation of the Python sample docs! Content of the sample descriptions/custom content is predominantly pulled from the existing docs
1 parent 221594a commit 3ecca7a

25 files changed

Lines changed: 481 additions & 1012 deletions

File tree

.repo-metadata.json

Lines changed: 55 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,59 @@
99
"repo": "googleapis/python-bigtable",
1010
"distribution_name": "google-cloud-bigtable",
1111
"api_id": "bigtable.googleapis.com",
12-
"requires_billing": true
12+
"requires_billing": true,
13+
"samples": [
14+
{"name": "Hello World in Cloud Bigtable",
15+
"description": "Demonstrates how to connect to Cloud Bigtable and run some basic operations. More information available at: https://cloud.google.com/bigtable/docs/samples-python-hello",
16+
"file": "main.py",
17+
"runnable": true,
18+
"custom_content": "<pre>usage: main.py [-h] [--table TABLE] project_id instance_id<br>Demonstrates how to connect to Cloud Bigtable and run some basic operations.<br>Prerequisites: - Create a Cloud Bigtable cluster.<br>https://cloud.google.com/bigtable/docs/creating-cluster - Set your Google<br>Application Default Credentials.<br>https://developers.google.com/identity/protocols/application-default-<br>credentials<br><br><br>positional arguments:<br>&nbsp; project_id &nbsp; &nbsp; Your Cloud Platform project ID.<br>&nbsp; instance_id &nbsp; &nbsp;ID of the Cloud Bigtable instance to connect to.<br><br><br>optional arguments:<br>&nbsp; -h, --help &nbsp; &nbsp; show this help message and exit<br>&nbsp; --table TABLE &nbsp;Table to create and destroy. (default: Hello-Bigtable)</pre>",
19+
"override_path": "hello"},
20+
21+
{"name": "Hello World using HappyBase",
22+
"description": "This sample demonstrates using the Google Cloud Client Library HappyBase package, an implementation of the HappyBase API to connect to and interact with Cloud Bigtable. More information available at: https://cloud.google.com/bigtable/docs/samples-python-hello-happybase",
23+
"file": "main.py",
24+
"runnable": true,
25+
"custom_content": "<pre>usage: main.py [-h] [--table TABLE] project_id instance_id<br>Demonstrates how to connect to Cloud Bigtable and run some basic operations.<br>Prerequisites: - Create a Cloud Bigtable cluster.<br>https://cloud.google.com/bigtable/docs/creating-cluster - Set your Google<br>Application Default Credentials.<br>https://developers.google.com/identity/protocols/application-default-<br>credentials<br><br><br>positional arguments:<br>&nbsp; project_id &nbsp; &nbsp; Your Cloud Platform project ID.<br>&nbsp; instance_id &nbsp; &nbsp;ID of the Cloud Bigtable instance to connect to.<br><br><br>optional arguments:<br>&nbsp; -h, --help &nbsp; &nbsp; show this help message and exit<br>&nbsp; --table TABLE &nbsp;Table to create and destroy. (default: Hello-Bigtable)</pre>",
26+
"override_path": "hello_happybase"},
27+
28+
{"name": "cbt Command Demonstration",
29+
"description": "This page explains how to use the cbt command to connect to a Cloud Bigtable instance, perform basic administrative tasks, and read and write data in a table. More information about this quickstart is available at https://cloud.google.com/bigtable/docs/quickstart-cbt",
30+
"file": "instanceadmin.py",
31+
"runnable": true,
32+
"custom_content" : "<pre>usage: instanceadmin.py [-h] [run] [dev-instance] [del-instance] [add-cluster] [del-cluster] project_id instance_id cluster_id<br>Demonstrates how to connect to Cloud Bigtable and run some basic operations.<br>Prerequisites: - Create a Cloud Bigtable cluster.<br>https://cloud.google.com/bigtable/docs/creating-cluster - Set your Google<br>Application Default Credentials.<br>https://developers.google.com/identity/protocols/application-default-<br>credentials<br><br><br>positional arguments:<br>&nbsp; project_id &nbsp; &nbsp; Your Cloud Platform project ID.<br>&nbsp; instance_id &nbsp; &nbsp;ID of the Cloud Bigtable instance to connect to.<br><br><br>optional arguments:<br>&nbsp; -h, --help &nbsp; &nbsp; show this help message and exit<br>&nbsp; --table TABLE &nbsp;Table to create and destroy. (default: Hello-Bigtable)</pre>",
33+
"override_path": "instanceadmin"},
34+
35+
{"name": "Metric Scaler",
36+
"description": "This sample demonstrates how to use Stackdriver Monitoring to scale Cloud Bigtable based on CPU usage.",
37+
"file": "metricscaler.py",
38+
"runnable": true,
39+
"custom_content": "<pre>usage: metricscaler.py [-h] [--high_cpu_threshold HIGH_CPU_THRESHOLD] [--low_cpu_threshold LOW_CPU_THRESHOLD] [--short_sleep SHORT_SLEEP] [--long_sleep LONG_SLEEP] bigtable_instance bigtable_cluster<br>usage: metricscaler.py [-h] [--high_cpu_threshold HIGH_CPU_THRESHOLD] <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;[--low_cpu_threshold LOW_CPU_THRESHOLD] <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;[--short_sleep SHORT_SLEEP] [--long_sleep LONG_SLEEP] <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;bigtable_instance bigtable_cluster <br><br> <br>Scales Cloud Bigtable clusters based on CPU usage. <br><br> <br>positional arguments: <br>&nbsp; bigtable_instance &nbsp; &nbsp; ID of the Cloud Bigtable instance to connect to. <br>&nbsp; bigtable_cluster &nbsp; &nbsp; &nbsp;ID of the Cloud Bigtable cluster to connect to. <br><br> <br>optional arguments: <br>&nbsp; -h, --help &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;show this help message and exit <br>&nbsp; --high_cpu_threshold HIGH_CPU_THRESHOLD <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; If Cloud Bigtable CPU usage is above this threshold, <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; scale up <br>&nbsp; --low_cpu_threshold LOW_CPU_THRESHOLD <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; If Cloud Bigtable CPU usage is below this threshold, <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; scale down <br>&nbsp; --short_sleep SHORT_SLEEP <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; How long to sleep in seconds between checking metrics <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; after no scale operation <br>&nbsp; --long_sleep LONG_SLEEP <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; How long to sleep in seconds between checking metrics <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; after a scaling operation</pre>",
40+
"override_path": "metricscaler"},
41+
42+
{"name": "Quickstart",
43+
"description": "Demonstrates of Cloud Bigtable. This sample creates a Bigtable client, connects to an instance and then to a table, then closes the connection.",
44+
"file": "main.py",
45+
"runnable": true,
46+
"custom_content": "<pre>usage: main.py [-h] [--table TABLE] project_id instance_id<br>usage: main.py [-h] [--table TABLE] project_id instance_id <br><br> <br>positional arguments: <br>&nbsp; project_id &nbsp; &nbsp; Your Cloud Platform project ID. <br>&nbsp; instance_id &nbsp; &nbsp;ID of the Cloud Bigtable instance to connect to. <br><br> <br>optional arguments: <br>&nbsp; -h, --help &nbsp; &nbsp; show this help message and exit <br>&nbsp; --table TABLE &nbsp;Existing table used in the quickstart. (default: my-table)</pre>",
47+
"override_path": "quickstart"},
48+
49+
{"name": "Quickstart using HappyBase",
50+
"description": "Demonstrates of Cloud Bigtable using HappyBase. This sample creates a Bigtable client, connects to an instance and then to a table, then closes the connection.",
51+
"file": "main.py",
52+
"runnable": true,
53+
"custom_content": "<pre>usage: main.py [-h] [--table TABLE] project_id instance_id<br>usage: main.py [-h] [--table TABLE] project_id instance_id <br><br> <br>positional arguments: <br>&nbsp; project_id &nbsp; &nbsp; Your Cloud Platform project ID. <br>&nbsp; instance_id &nbsp; &nbsp;ID of the Cloud Bigtable instance to connect to. <br><br> <br>optional arguments: <br>&nbsp; -h, --help &nbsp; &nbsp; show this help message and exit <br>&nbsp; --table TABLE &nbsp;Existing table used in the quickstart. (default: my-table)</code",
54+
"override_path": "quickstart_happybase"},
55+
56+
{"name": "Snippets",
57+
"description": "This folder contains snippets for Python Cloud Bigtable.",
58+
"override_path": "snippets"},
59+
60+
{"name": "Table Admin",
61+
"description": "Demonstrates how to connect to Cloud Bigtable and run some basic operations.",
62+
"file": "tableadmin.py",
63+
"runnable": true,
64+
"custom_content": "<pre>usage: tableadmin.py [-h] [run] [delete] [--table TABLE] project_id instance_id<br>usage: tableadmin.py [-h] [run] [delete] [--table TABLE] project_id instance_id <br><br> <br>Demonstrates how to connect to Cloud Bigtable and run some basic operations. <br>Prerequisites: - Create a Cloud Bigtable cluster. <br>https://cloud.google.com/bigtable/docs/creating-cluster - Set your Google <br>Application Default Credentials. <br>https://developers.google.com/identity/protocols/application-default- <br>credentials <br><br> <br>positional arguments: <br>&nbsp; project_id &nbsp; &nbsp; Your Cloud Platform project ID. <br>&nbsp; instance_id &nbsp; &nbsp;ID of the Cloud Bigtable instance to connect to. <br><br> <br>optional arguments: <br>&nbsp; -h, --help &nbsp; &nbsp; show this help message and exit <br>&nbsp; --table TABLE &nbsp;Table to create and destroy. (default: Hello-Bigtable)</pre>",
65+
"override_path": "tableadmin"}
66+
]
1367
}

samples/README.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
[//]: # "This README.md file is auto-generated, all changes to this file will be lost."
2+
[//]: # "To regenerate it, use `python -m synthtool`."
3+
4+
## Python Samples for Cloud Bigtable
5+
6+
This directory contains samples for Cloud Bigtable, which may be used as a refererence for how to use Cloud Bigtable.
7+
8+
## Additional Information
9+
10+
You can read the documentation for more details on API usage and use GitHub
11+
to [browse the source][source] and [report issues][issues].
12+
13+
### Contributing
14+
For [contributing guidelines][contrib_guide], the [Python style guide][py_style], and more information on prerequisite steps to contribute, view the source code at <a href="https://github.com/googleapis/python-bigtable">googleapis/python-bigtable</a>.
15+
16+
[authentication]: https://cloud.google.com/docs/authentication/getting-started
17+
[enable_billing]:https://cloud.google.com/apis/docs/getting-started#enabling_billing
18+
[client_library_python]: https://googlecloudplatform.github.io/google-cloud-python/
19+
[source]: https://github.com/GoogleCloudPlatform/google-cloud-python
20+
[issues]: https://github.com/GoogleCloudPlatform/google-cloud-python/issues
21+
[contrib_guide]: https://github.com/googleapis/google-cloud-python/blob/master/CONTRIBUTING.rst
22+
[py_style]: http://google.github.io/styleguide/pyguide.html
23+
[cloud_sdk]: https://cloud.google.com/sdk/docs
24+
[gcloud_shell]: https://cloud.google.com/shell/docs
25+
[gcloud_shell]: https://cloud.google.com/shell/docs

samples/hello/README.md

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
[//]: # "This README.md file is auto-generated, all changes to this file will be lost."
2+
[//]: # "To regenerate it, use `python -m synthtool`."
3+
4+
## Python Samples for Cloud Bigtable
5+
6+
This directory contains samples for Cloud Bigtable, which may be used as a refererence for how to use Cloud Bigtable.
7+
Samples, quickstarts, and other documentation are available at <a href="https://cloud.google.com/bigtable">cloud.google.com</a>.
8+
9+
10+
### Hello World in Cloud Bigtable
11+
12+
Demonstrates how to connect to Cloud Bigtable and run some basic operations. More information available at: https://cloud.google.com/bigtable/docs/samples-python-hello
13+
14+
15+
<a href="https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/python-bigtable&page=editor&open_in_editor=main.py"><img alt="Open in Cloud Shell" src="http://gstatic.com/cloudssh/images/open-btn.png">
16+
</a>
17+
18+
To run this sample:
19+
20+
1. If this is your first time working with GCP products, you will need to set up [the Cloud SDK][cloud_sdk] or utilize [Google Cloud Shell][gcloud_shell]. This sample may [require authetication][authentication] and you will need to [enable billing][enable_billing].
21+
22+
1. Make a fork of this repo and clone the branch locally, then navigate to the sample directory you want to use.
23+
24+
1. Install the dependencies needed to run the samples.
25+
26+
pip install -r requirements.txt
27+
28+
1. Run the sample using
29+
30+
python main.py
31+
32+
33+
<pre>usage: main.py [-h] [--table TABLE] project_id instance_id<br>Demonstrates how to connect to Cloud Bigtable and run some basic operations.<br>Prerequisites: - Create a Cloud Bigtable cluster.<br>https://cloud.google.com/bigtable/docs/creating-cluster - Set your Google<br>Application Default Credentials.<br>https://developers.google.com/identity/protocols/application-default-<br>credentials<br><br><br>positional arguments:<br>&nbsp; project_id &nbsp; &nbsp; Your Cloud Platform project ID.<br>&nbsp; instance_id &nbsp; &nbsp;ID of the Cloud Bigtable instance to connect to.<br><br><br>optional arguments:<br>&nbsp; -h, --help &nbsp; &nbsp; show this help message and exit<br>&nbsp; --table TABLE &nbsp;Table to create and destroy. (default: Hello-Bigtable)</pre>
34+
35+
## Additional Information
36+
37+
You can read the documentation for more details on API usage and use GitHub
38+
to [browse the source][source] and [report issues][issues].
39+
40+
### Contributing
41+
For [contributing guidelines][contrib_guide], the [Python style guide][py_style], and more information on prerequisite steps to contribute, view the source code at <a href="https://github.com/googleapis/python-bigtable">googleapis/python-bigtable</a>.
42+
43+
[authentication]: https://cloud.google.com/docs/authentication/getting-started
44+
[enable_billing]:https://cloud.google.com/apis/docs/getting-started#enabling_billing
45+
[client_library_python]: https://googlecloudplatform.github.io/google-cloud-python/
46+
[source]: https://github.com/GoogleCloudPlatform/google-cloud-python
47+
[issues]: https://github.com/GoogleCloudPlatform/google-cloud-python/issues
48+
[contrib_guide]: https://github.com/googleapis/google-cloud-python/blob/master/CONTRIBUTING.rst
49+
[py_style]: http://google.github.io/styleguide/pyguide.html
50+
[cloud_sdk]: https://cloud.google.com/sdk/docs
51+
[gcloud_shell]: https://cloud.google.com/shell/docs
52+
[gcloud_shell]: https://cloud.google.com/shell/docs

samples/hello/README.rst

Lines changed: 0 additions & 115 deletions
This file was deleted.

samples/hello/README.rst.in

Lines changed: 0 additions & 23 deletions
This file was deleted.

0 commit comments

Comments
 (0)