From 3ecca7a7b52b0f4fc38db5c5016622b994c1a8aa Mon Sep 17 00:00:00 2001 From: Alexa B Date: Fri, 21 Aug 2020 18:44:02 -0400 Subject: [PATCH] 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 --- .repo-metadata.json | 56 ++++++++- samples/README.md | 25 ++++ samples/hello/README.md | 52 +++++++++ samples/hello/README.rst | 115 ------------------ samples/hello/README.rst.in | 23 ---- samples/hello_happybase/README.md | 52 +++++++++ samples/hello_happybase/README.rst | 122 -------------------- samples/hello_happybase/README.rst.in | 32 ------ samples/instanceadmin/README.md | 52 +++++++++ samples/instanceadmin/README.rst | 120 ------------------- samples/instanceadmin/README.rst.in | 23 ---- samples/metricscaler/README.md | 52 +++++++++ samples/metricscaler/README.rst | 128 --------------------- samples/metricscaler/README.rst.in | 29 ----- samples/quickstart/README.md | 52 +++++++++ samples/quickstart/README.rst | 126 -------------------- samples/quickstart/README.rst.in | 23 ---- samples/quickstart_happybase/README.md | 52 +++++++++ samples/quickstart_happybase/README.rst | 108 ----------------- samples/quickstart_happybase/README.rst.in | 23 ---- samples/snippets/README.md | 33 ++++++ samples/tableadmin/README.md | 52 +++++++++ samples/tableadmin/README.rst | 115 ------------------ samples/tableadmin/README.rst.in | 23 ---- synth.py | 5 +- 25 files changed, 481 insertions(+), 1012 deletions(-) create mode 100644 samples/README.md create mode 100644 samples/hello/README.md delete mode 100644 samples/hello/README.rst delete mode 100644 samples/hello/README.rst.in create mode 100644 samples/hello_happybase/README.md delete mode 100644 samples/hello_happybase/README.rst delete mode 100644 samples/hello_happybase/README.rst.in create mode 100644 samples/instanceadmin/README.md delete mode 100644 samples/instanceadmin/README.rst delete mode 100644 samples/instanceadmin/README.rst.in create mode 100644 samples/metricscaler/README.md delete mode 100644 samples/metricscaler/README.rst delete mode 100644 samples/metricscaler/README.rst.in create mode 100644 samples/quickstart/README.md delete mode 100644 samples/quickstart/README.rst delete mode 100644 samples/quickstart/README.rst.in create mode 100644 samples/quickstart_happybase/README.md delete mode 100644 samples/quickstart_happybase/README.rst delete mode 100644 samples/quickstart_happybase/README.rst.in create mode 100644 samples/snippets/README.md create mode 100644 samples/tableadmin/README.md delete mode 100644 samples/tableadmin/README.rst delete mode 100644 samples/tableadmin/README.rst.in diff --git a/.repo-metadata.json b/.repo-metadata.json index cfda5a11e..7c1f86991 100644 --- a/.repo-metadata.json +++ b/.repo-metadata.json @@ -9,5 +9,59 @@ "repo": "googleapis/python-bigtable", "distribution_name": "google-cloud-bigtable", "api_id": "bigtable.googleapis.com", - "requires_billing": true + "requires_billing": true, + "samples": [ + {"name": "Hello World in Cloud Bigtable", + "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", + "file": "main.py", + "runnable": true, + "custom_content": "
usage: main.py [-h] [--table TABLE] project_id instance_id
Demonstrates how to connect to Cloud Bigtable and run some basic operations.
Prerequisites: - Create a Cloud Bigtable cluster.
https://cloud.google.com/bigtable/docs/creating-cluster - Set your Google
Application Default Credentials.
https://developers.google.com/identity/protocols/application-default-
credentials


positional arguments:
  project_id     Your Cloud Platform project ID.
  instance_id    ID of the Cloud Bigtable instance to connect to.


optional arguments:
  -h, --help     show this help message and exit
  --table TABLE  Table to create and destroy. (default: Hello-Bigtable)
", + "override_path": "hello"}, + + {"name": "Hello World using HappyBase", + "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", + "file": "main.py", + "runnable": true, + "custom_content": "
usage: main.py [-h] [--table TABLE] project_id instance_id
Demonstrates how to connect to Cloud Bigtable and run some basic operations.
Prerequisites: - Create a Cloud Bigtable cluster.
https://cloud.google.com/bigtable/docs/creating-cluster - Set your Google
Application Default Credentials.
https://developers.google.com/identity/protocols/application-default-
credentials


positional arguments:
  project_id     Your Cloud Platform project ID.
  instance_id    ID of the Cloud Bigtable instance to connect to.


optional arguments:
  -h, --help     show this help message and exit
  --table TABLE  Table to create and destroy. (default: Hello-Bigtable)
", + "override_path": "hello_happybase"}, + + {"name": "cbt Command Demonstration", + "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", + "file": "instanceadmin.py", + "runnable": true, + "custom_content" : "
usage: instanceadmin.py [-h] [run] [dev-instance] [del-instance] [add-cluster] [del-cluster] project_id instance_id cluster_id
Demonstrates how to connect to Cloud Bigtable and run some basic operations.
Prerequisites: - Create a Cloud Bigtable cluster.
https://cloud.google.com/bigtable/docs/creating-cluster - Set your Google
Application Default Credentials.
https://developers.google.com/identity/protocols/application-default-
credentials


positional arguments:
  project_id     Your Cloud Platform project ID.
  instance_id    ID of the Cloud Bigtable instance to connect to.


optional arguments:
  -h, --help     show this help message and exit
  --table TABLE  Table to create and destroy. (default: Hello-Bigtable)
", + "override_path": "instanceadmin"}, + + {"name": "Metric Scaler", + "description": "This sample demonstrates how to use Stackdriver Monitoring to scale Cloud Bigtable based on CPU usage.", + "file": "metricscaler.py", + "runnable": true, + "custom_content": "
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
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


Scales Cloud Bigtable clusters based on CPU usage.


positional arguments:
  bigtable_instance     ID of the Cloud Bigtable instance to connect to.
  bigtable_cluster      ID of the Cloud Bigtable cluster to connect to.


optional arguments:
  -h, --help            show this help message and exit
  --high_cpu_threshold HIGH_CPU_THRESHOLD
                        If Cloud Bigtable CPU usage is above this threshold,
                        scale up
  --low_cpu_threshold LOW_CPU_THRESHOLD
                        If Cloud Bigtable CPU usage is below this threshold,
                        scale down
  --short_sleep SHORT_SLEEP
                        How long to sleep in seconds between checking metrics
                        after no scale operation
  --long_sleep LONG_SLEEP
                        How long to sleep in seconds between checking metrics
                        after a scaling operation
", + "override_path": "metricscaler"}, + + {"name": "Quickstart", + "description": "Demonstrates of Cloud Bigtable. This sample creates a Bigtable client, connects to an instance and then to a table, then closes the connection.", + "file": "main.py", + "runnable": true, + "custom_content": "
usage: main.py [-h] [--table TABLE] project_id instance_id
usage: main.py [-h] [--table TABLE] project_id instance_id


positional arguments:
  project_id     Your Cloud Platform project ID.
  instance_id    ID of the Cloud Bigtable instance to connect to.


optional arguments:
  -h, --help     show this help message and exit
  --table TABLE  Existing table used in the quickstart. (default: my-table)
", + "override_path": "quickstart"}, + + {"name": "Quickstart using HappyBase", + "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.", + "file": "main.py", + "runnable": true, + "custom_content": "
usage: main.py [-h] [--table TABLE] project_id instance_id
usage: main.py [-h] [--table TABLE] project_id instance_id


positional arguments:
  project_id     Your Cloud Platform project ID.
  instance_id    ID of the Cloud Bigtable instance to connect to.


optional arguments:
  -h, --help     show this help message and exit
  --table TABLE  Existing table used in the quickstart. (default: my-table)usage: tableadmin.py [-h] [run] [delete] [--table TABLE] project_id instance_id
usage: tableadmin.py [-h] [run] [delete] [--table TABLE] project_id instance_id


Demonstrates how to connect to Cloud Bigtable and run some basic operations.
Prerequisites: - Create a Cloud Bigtable cluster.
https://cloud.google.com/bigtable/docs/creating-cluster - Set your Google
Application Default Credentials.
https://developers.google.com/identity/protocols/application-default-
credentials


positional arguments:
  project_id     Your Cloud Platform project ID.
  instance_id    ID of the Cloud Bigtable instance to connect to.


optional arguments:
  -h, --help     show this help message and exit
  --table TABLE  Table to create and destroy. (default: Hello-Bigtable)
", + "override_path": "tableadmin"} + ] } \ No newline at end of file diff --git a/samples/README.md b/samples/README.md new file mode 100644 index 000000000..ae3123e7f --- /dev/null +++ b/samples/README.md @@ -0,0 +1,25 @@ +[//]: # "This README.md file is auto-generated, all changes to this file will be lost." +[//]: # "To regenerate it, use `python -m synthtool`." + +## Python Samples for Cloud Bigtable + +This directory contains samples for Cloud Bigtable, which may be used as a refererence for how to use Cloud Bigtable. + +## Additional Information + +You can read the documentation for more details on API usage and use GitHub +to [browse the source][source] and [report issues][issues]. + +### Contributing +For [contributing guidelines][contrib_guide], the [Python style guide][py_style], and more information on prerequisite steps to contribute, view the source code at googleapis/python-bigtable. + +[authentication]: https://cloud.google.com/docs/authentication/getting-started +[enable_billing]:https://cloud.google.com/apis/docs/getting-started#enabling_billing +[client_library_python]: https://googlecloudplatform.github.io/google-cloud-python/ +[source]: https://github.com/GoogleCloudPlatform/google-cloud-python +[issues]: https://github.com/GoogleCloudPlatform/google-cloud-python/issues +[contrib_guide]: https://github.com/googleapis/google-cloud-python/blob/master/CONTRIBUTING.rst +[py_style]: http://google.github.io/styleguide/pyguide.html +[cloud_sdk]: https://cloud.google.com/sdk/docs +[gcloud_shell]: https://cloud.google.com/shell/docs +[gcloud_shell]: https://cloud.google.com/shell/docs diff --git a/samples/hello/README.md b/samples/hello/README.md new file mode 100644 index 000000000..0fa601de7 --- /dev/null +++ b/samples/hello/README.md @@ -0,0 +1,52 @@ +[//]: # "This README.md file is auto-generated, all changes to this file will be lost." +[//]: # "To regenerate it, use `python -m synthtool`." + +## Python Samples for Cloud Bigtable + +This directory contains samples for Cloud Bigtable, which may be used as a refererence for how to use Cloud Bigtable. +Samples, quickstarts, and other documentation are available at cloud.google.com. + + +### Hello World in Cloud Bigtable + +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 + + +Open in Cloud Shell + + +To run this sample: + +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]. + +1. Make a fork of this repo and clone the branch locally, then navigate to the sample directory you want to use. + +1. Install the dependencies needed to run the samples. + + pip install -r requirements.txt + +1. Run the sample using + + python main.py + + +
usage: main.py [-h] [--table TABLE] project_id instance_id
Demonstrates how to connect to Cloud Bigtable and run some basic operations.
Prerequisites: - Create a Cloud Bigtable cluster.
https://cloud.google.com/bigtable/docs/creating-cluster - Set your Google
Application Default Credentials.
https://developers.google.com/identity/protocols/application-default-
credentials


positional arguments:
  project_id     Your Cloud Platform project ID.
  instance_id    ID of the Cloud Bigtable instance to connect to.


optional arguments:
  -h, --help     show this help message and exit
  --table TABLE  Table to create and destroy. (default: Hello-Bigtable)
+ +## Additional Information + +You can read the documentation for more details on API usage and use GitHub +to [browse the source][source] and [report issues][issues]. + +### Contributing +For [contributing guidelines][contrib_guide], the [Python style guide][py_style], and more information on prerequisite steps to contribute, view the source code at googleapis/python-bigtable. + +[authentication]: https://cloud.google.com/docs/authentication/getting-started +[enable_billing]:https://cloud.google.com/apis/docs/getting-started#enabling_billing +[client_library_python]: https://googlecloudplatform.github.io/google-cloud-python/ +[source]: https://github.com/GoogleCloudPlatform/google-cloud-python +[issues]: https://github.com/GoogleCloudPlatform/google-cloud-python/issues +[contrib_guide]: https://github.com/googleapis/google-cloud-python/blob/master/CONTRIBUTING.rst +[py_style]: http://google.github.io/styleguide/pyguide.html +[cloud_sdk]: https://cloud.google.com/sdk/docs +[gcloud_shell]: https://cloud.google.com/shell/docs +[gcloud_shell]: https://cloud.google.com/shell/docs diff --git a/samples/hello/README.rst b/samples/hello/README.rst deleted file mode 100644 index 893932ad5..000000000 --- a/samples/hello/README.rst +++ /dev/null @@ -1,115 +0,0 @@ -.. This file is automatically generated. Do not edit this file directly. - -Google Cloud Bigtable Python Samples -=============================================================================== - -.. image:: https://gstatic.com/cloudssh/images/open-btn.png - :target: https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/GoogleCloudPlatform/python-docs-samples&page=editor&open_in_editor=bigtable/hello/README.rst - - -This directory contains samples for Google Cloud Bigtable. `Google Cloud Bigtable`_ is Google's NoSQL Big Data database service. It's the same database that powers many core Google services, including Search, Analytics, Maps, and Gmail. - - - - -.. _Google Cloud Bigtable: https://cloud.google.com/bigtable/docs - -Setup -------------------------------------------------------------------------------- - - -Authentication -++++++++++++++ - -This sample requires you to have authentication setup. Refer to the -`Authentication Getting Started Guide`_ for instructions on setting up -credentials for applications. - -.. _Authentication Getting Started Guide: - https://cloud.google.com/docs/authentication/getting-started - -Install Dependencies -++++++++++++++++++++ - -#. Clone python-docs-samples and change directory to the sample directory you want to use. - - .. code-block:: bash - - $ git clone https://github.com/GoogleCloudPlatform/python-docs-samples.git - -#. Install `pip`_ and `virtualenv`_ if you do not already have them. You may want to refer to the `Python Development Environment Setup Guide`_ for Google Cloud Platform for instructions. - - .. _Python Development Environment Setup Guide: - https://cloud.google.com/python/setup - -#. Create a virtualenv. Samples are compatible with Python 2.7 and 3.4+. - - .. code-block:: bash - - $ virtualenv env - $ source env/bin/activate - -#. Install the dependencies needed to run the samples. - - .. code-block:: bash - - $ pip install -r requirements.txt - -.. _pip: https://pip.pypa.io/ -.. _virtualenv: https://virtualenv.pypa.io/ - -Samples -------------------------------------------------------------------------------- - -Basic example -+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - -.. image:: https://gstatic.com/cloudssh/images/open-btn.png - :target: https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/GoogleCloudPlatform/python-docs-samples&page=editor&open_in_editor=bigtable/hello/main.py,bigtable/hello/README.rst - - - - -To run this sample: - -.. code-block:: bash - - $ python main.py - - usage: main.py [-h] [--table TABLE] project_id instance_id - - Demonstrates how to connect to Cloud Bigtable and run some basic operations. - Prerequisites: - Create a Cloud Bigtable cluster. - https://cloud.google.com/bigtable/docs/creating-cluster - Set your Google - Application Default Credentials. - https://developers.google.com/identity/protocols/application-default- - credentials - - positional arguments: - project_id Your Cloud Platform project ID. - instance_id ID of the Cloud Bigtable instance to connect to. - - optional arguments: - -h, --help show this help message and exit - --table TABLE Table to create and destroy. (default: Hello-Bigtable) - - - - - -The client library -------------------------------------------------------------------------------- - -This sample uses the `Google Cloud Client Library for Python`_. -You can read the documentation for more details on API usage and use GitHub -to `browse the source`_ and `report issues`_. - -.. _Google Cloud Client Library for Python: - https://googlecloudplatform.github.io/google-cloud-python/ -.. _browse the source: - https://github.com/GoogleCloudPlatform/google-cloud-python -.. _report issues: - https://github.com/GoogleCloudPlatform/google-cloud-python/issues - - -.. _Google Cloud SDK: https://cloud.google.com/sdk/ \ No newline at end of file diff --git a/samples/hello/README.rst.in b/samples/hello/README.rst.in deleted file mode 100644 index ed9253c11..000000000 --- a/samples/hello/README.rst.in +++ /dev/null @@ -1,23 +0,0 @@ -# This file is used to generate README.rst - -product: - name: Google Cloud Bigtable - short_name: Cloud Bigtable - url: https://cloud.google.com/bigtable/docs - description: > - `Google Cloud Bigtable`_ is Google's NoSQL Big Data database service. It's - the same database that powers many core Google services, including Search, - Analytics, Maps, and Gmail. - -setup: -- auth -- install_deps - -samples: -- name: Basic example - file: main.py - show_help: true - -cloud_client_library: true - -folder: bigtable/hello \ No newline at end of file diff --git a/samples/hello_happybase/README.md b/samples/hello_happybase/README.md new file mode 100644 index 000000000..c56e68e4b --- /dev/null +++ b/samples/hello_happybase/README.md @@ -0,0 +1,52 @@ +[//]: # "This README.md file is auto-generated, all changes to this file will be lost." +[//]: # "To regenerate it, use `python -m synthtool`." + +## Python Samples for Cloud Bigtable + +This directory contains samples for Cloud Bigtable, which may be used as a refererence for how to use Cloud Bigtable. +Samples, quickstarts, and other documentation are available at cloud.google.com. + + +### Hello World using HappyBase + +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 + + +Open in Cloud Shell + + +To run this sample: + +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]. + +1. Make a fork of this repo and clone the branch locally, then navigate to the sample directory you want to use. + +1. Install the dependencies needed to run the samples. + + pip install -r requirements.txt + +1. Run the sample using + + python main.py + + +
usage: main.py [-h] [--table TABLE] project_id instance_id
Demonstrates how to connect to Cloud Bigtable and run some basic operations.
Prerequisites: - Create a Cloud Bigtable cluster.
https://cloud.google.com/bigtable/docs/creating-cluster - Set your Google
Application Default Credentials.
https://developers.google.com/identity/protocols/application-default-
credentials


positional arguments:
  project_id     Your Cloud Platform project ID.
  instance_id    ID of the Cloud Bigtable instance to connect to.


optional arguments:
  -h, --help     show this help message and exit
  --table TABLE  Table to create and destroy. (default: Hello-Bigtable)
+ +## Additional Information + +You can read the documentation for more details on API usage and use GitHub +to [browse the source][source] and [report issues][issues]. + +### Contributing +For [contributing guidelines][contrib_guide], the [Python style guide][py_style], and more information on prerequisite steps to contribute, view the source code at googleapis/python-bigtable. + +[authentication]: https://cloud.google.com/docs/authentication/getting-started +[enable_billing]:https://cloud.google.com/apis/docs/getting-started#enabling_billing +[client_library_python]: https://googlecloudplatform.github.io/google-cloud-python/ +[source]: https://github.com/GoogleCloudPlatform/google-cloud-python +[issues]: https://github.com/GoogleCloudPlatform/google-cloud-python/issues +[contrib_guide]: https://github.com/googleapis/google-cloud-python/blob/master/CONTRIBUTING.rst +[py_style]: http://google.github.io/styleguide/pyguide.html +[cloud_sdk]: https://cloud.google.com/sdk/docs +[gcloud_shell]: https://cloud.google.com/shell/docs +[gcloud_shell]: https://cloud.google.com/shell/docs diff --git a/samples/hello_happybase/README.rst b/samples/hello_happybase/README.rst deleted file mode 100644 index 82a376535..000000000 --- a/samples/hello_happybase/README.rst +++ /dev/null @@ -1,122 +0,0 @@ -.. This file is automatically generated. Do not edit this file directly. - -Google Cloud Bigtable Python Samples -=============================================================================== - -.. image:: https://gstatic.com/cloudssh/images/open-btn.png - :target: https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/GoogleCloudPlatform/python-docs-samples&page=editor&open_in_editor=bigtable/hello_happybase/README.rst - - -This directory contains samples for Google Cloud Bigtable. `Google Cloud Bigtable`_ is Google's NoSQL Big Data database service. It's the same database that powers many core Google services, including Search, Analytics, Maps, and Gmail. - - -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. - -.. _Google Cloud Client Library HappyBase package: - https://github.com/GoogleCloudPlatform/google-cloud-python-happybase -.. _HappyBase API: http://happybase.readthedocs.io/en/stable/ - - -.. _Google Cloud Bigtable: https://cloud.google.com/bigtable/docs - -Setup -------------------------------------------------------------------------------- - - -Authentication -++++++++++++++ - -This sample requires you to have authentication setup. Refer to the -`Authentication Getting Started Guide`_ for instructions on setting up -credentials for applications. - -.. _Authentication Getting Started Guide: - https://cloud.google.com/docs/authentication/getting-started - -Install Dependencies -++++++++++++++++++++ - -#. Clone python-docs-samples and change directory to the sample directory you want to use. - - .. code-block:: bash - - $ git clone https://github.com/GoogleCloudPlatform/python-docs-samples.git - -#. Install `pip`_ and `virtualenv`_ if you do not already have them. You may want to refer to the `Python Development Environment Setup Guide`_ for Google Cloud Platform for instructions. - - .. _Python Development Environment Setup Guide: - https://cloud.google.com/python/setup - -#. Create a virtualenv. Samples are compatible with Python 2.7 and 3.4+. - - .. code-block:: bash - - $ virtualenv env - $ source env/bin/activate - -#. Install the dependencies needed to run the samples. - - .. code-block:: bash - - $ pip install -r requirements.txt - -.. _pip: https://pip.pypa.io/ -.. _virtualenv: https://virtualenv.pypa.io/ - -Samples -------------------------------------------------------------------------------- - -Basic example -+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - -.. image:: https://gstatic.com/cloudssh/images/open-btn.png - :target: https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/GoogleCloudPlatform/python-docs-samples&page=editor&open_in_editor=bigtable/hello_happybase/main.py,bigtable/hello_happybase/README.rst - - - - -To run this sample: - -.. code-block:: bash - - $ python main.py - - usage: main.py [-h] [--table TABLE] project_id instance_id - - Demonstrates how to connect to Cloud Bigtable and run some basic operations. - Prerequisites: - Create a Cloud Bigtable cluster. - https://cloud.google.com/bigtable/docs/creating-cluster - Set your Google - Application Default Credentials. - https://developers.google.com/identity/protocols/application-default- - credentials - - positional arguments: - project_id Your Cloud Platform project ID. - instance_id ID of the Cloud Bigtable instance to connect to. - - optional arguments: - -h, --help show this help message and exit - --table TABLE Table to create and destroy. (default: Hello-Bigtable) - - - - - -The client library -------------------------------------------------------------------------------- - -This sample uses the `Google Cloud Client Library for Python`_. -You can read the documentation for more details on API usage and use GitHub -to `browse the source`_ and `report issues`_. - -.. _Google Cloud Client Library for Python: - https://googlecloudplatform.github.io/google-cloud-python/ -.. _browse the source: - https://github.com/GoogleCloudPlatform/google-cloud-python -.. _report issues: - https://github.com/GoogleCloudPlatform/google-cloud-python/issues - - -.. _Google Cloud SDK: https://cloud.google.com/sdk/ \ No newline at end of file diff --git a/samples/hello_happybase/README.rst.in b/samples/hello_happybase/README.rst.in deleted file mode 100644 index 8ef6a956b..000000000 --- a/samples/hello_happybase/README.rst.in +++ /dev/null @@ -1,32 +0,0 @@ -# This file is used to generate README.rst - -product: - name: Google Cloud Bigtable - short_name: Cloud Bigtable - url: https://cloud.google.com/bigtable/docs - description: > - `Google Cloud Bigtable`_ is Google's NoSQL Big Data database service. It's - the same database that powers many core Google services, including Search, - Analytics, Maps, and Gmail. - -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. - - .. _Google Cloud Client Library HappyBase package: - https://github.com/GoogleCloudPlatform/google-cloud-python-happybase - .. _HappyBase API: http://happybase.readthedocs.io/en/stable/ - -setup: -- auth -- install_deps - -samples: -- name: Basic example - file: main.py - show_help: true - -cloud_client_library: true - -folder: bigtable/hello_happybase \ No newline at end of file diff --git a/samples/instanceadmin/README.md b/samples/instanceadmin/README.md new file mode 100644 index 000000000..e6ee71ad5 --- /dev/null +++ b/samples/instanceadmin/README.md @@ -0,0 +1,52 @@ +[//]: # "This README.md file is auto-generated, all changes to this file will be lost." +[//]: # "To regenerate it, use `python -m synthtool`." + +## Python Samples for Cloud Bigtable + +This directory contains samples for Cloud Bigtable, which may be used as a refererence for how to use Cloud Bigtable. +Samples, quickstarts, and other documentation are available at cloud.google.com. + + +### cbt Command Demonstration + +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 + + +Open in Cloud Shell + + +To run this sample: + +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]. + +1. Make a fork of this repo and clone the branch locally, then navigate to the sample directory you want to use. + +1. Install the dependencies needed to run the samples. + + pip install -r requirements.txt + +1. Run the sample using + + python instanceadmin.py + + +
usage: instanceadmin.py [-h] [run] [dev-instance] [del-instance] [add-cluster] [del-cluster] project_id instance_id cluster_id
Demonstrates how to connect to Cloud Bigtable and run some basic operations.
Prerequisites: - Create a Cloud Bigtable cluster.
https://cloud.google.com/bigtable/docs/creating-cluster - Set your Google
Application Default Credentials.
https://developers.google.com/identity/protocols/application-default-
credentials


positional arguments:
  project_id     Your Cloud Platform project ID.
  instance_id    ID of the Cloud Bigtable instance to connect to.


optional arguments:
  -h, --help     show this help message and exit
  --table TABLE  Table to create and destroy. (default: Hello-Bigtable)
+ +## Additional Information + +You can read the documentation for more details on API usage and use GitHub +to [browse the source][source] and [report issues][issues]. + +### Contributing +For [contributing guidelines][contrib_guide], the [Python style guide][py_style], and more information on prerequisite steps to contribute, view the source code at googleapis/python-bigtable. + +[authentication]: https://cloud.google.com/docs/authentication/getting-started +[enable_billing]:https://cloud.google.com/apis/docs/getting-started#enabling_billing +[client_library_python]: https://googlecloudplatform.github.io/google-cloud-python/ +[source]: https://github.com/GoogleCloudPlatform/google-cloud-python +[issues]: https://github.com/GoogleCloudPlatform/google-cloud-python/issues +[contrib_guide]: https://github.com/googleapis/google-cloud-python/blob/master/CONTRIBUTING.rst +[py_style]: http://google.github.io/styleguide/pyguide.html +[cloud_sdk]: https://cloud.google.com/sdk/docs +[gcloud_shell]: https://cloud.google.com/shell/docs +[gcloud_shell]: https://cloud.google.com/shell/docs diff --git a/samples/instanceadmin/README.rst b/samples/instanceadmin/README.rst deleted file mode 100644 index 16f176a60..000000000 --- a/samples/instanceadmin/README.rst +++ /dev/null @@ -1,120 +0,0 @@ -.. This file is automatically generated. Do not edit this file directly. - - -Google Cloud Bigtable table creation -=============================================================================== - -https://cloud.google.com/bigtable/docs/quickstart-cbt - -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. - -Google Cloud Bigtable Python Samples -=============================================================================== - -.. image:: https://gstatic.com/cloudssh/images/open-btn.png - :target: https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/GoogleCloudPlatform/python-docs-samples&page=editor&open_in_editor=bigtable/hello/README.rst - - -This directory contains samples for Google Cloud Bigtable. `Google Cloud Bigtable`_ is Google's NoSQL Big Data database service. It's the same database that powers many core Google services, including Search, Analytics, Maps, and Gmail. - - - - -.. _Google Cloud Bigtable: https://cloud.google.com/bigtable/docs - -Setup -------------------------------------------------------------------------------- - - -Authentication -++++++++++++++ - -This sample requires you to have authentication setup. Refer to the -`Authentication Getting Started Guide`_ for instructions on setting up -credentials for applications. - -.. _Authentication Getting Started Guide: - https://cloud.google.com/docs/authentication/getting-started - -Install Dependencies -++++++++++++++++++++ - -#. Clone python-docs-samples and change directory to the sample directory you want to use. - - .. code-block:: bash - - $ git clone https://github.com/GoogleCloudPlatform/python-docs-samples.git - -#. Install `pip`_ and `virtualenv`_ if you do not already have them. You may want to refer to the `Python Development Environment Setup Guide`_ for Google Cloud Platform for instructions. - - .. _Python Development Environment Setup Guide: - https://cloud.google.com/python/setup - -#. Create a virtualenv. Samples are compatible with Python 2.7 and 3.4+. - - .. code-block:: bash - - $ virtualenv env - $ source env/bin/activate - -#. Install the dependencies needed to run the samples. - - .. code-block:: bash - - $ pip install -r requirements.txt - -.. _pip: https://pip.pypa.io/ -.. _virtualenv: https://virtualenv.pypa.io/ - -Samples -------------------------------------------------------------------------------- - -Basic example -+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - -.. image:: https://gstatic.com/cloudssh/images/open-btn.png - :target: https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/GoogleCloudPlatform/python-docs-samples&page=editor&open_in_editor=bigtable/instanceadmin.py,bigtable/instanceadmin/README.rst - - - - -To run this sample: - -.. code-block:: bash - - $ python instanceadmin.py - - usage: instanceadmin.py [-h] [run] [dev-instance] [del-instance] [add-cluster] [del-cluster] project_id instance_id cluster_id - - Demonstrates how to connect to Cloud Bigtable and run some basic operations - to create instance, create cluster, delete instance and delete cluster. - Prerequisites: - Create a Cloud Bigtable cluster. - https://cloud.google.com/bigtable/docs/creating-cluster - Set your Google - Application Default Credentials. - https://developers.google.com/identity/protocols/application-default- - credentials - - positional arguments: - project_id Your Cloud Platform project ID. - instance_id ID of the Cloud Bigtable instance to connect to. - cluster_id ID of the Cloud Bigtable cluster to connect to. - - optional arguments: - -h, --help show this help message and exit - -The client library -------------------------------------------------------------------------------- - -This sample uses the `Google Cloud Client Library for Python`_. -You can read the documentation for more details on API usage and use GitHub -to `browse the source`_ and `report issues`_. - -.. _Google Cloud Client Library for Python: - https://googlecloudplatform.github.io/google-cloud-python/ -.. _browse the source: - https://github.com/GoogleCloudPlatform/google-cloud-python -.. _report issues: - https://github.com/GoogleCloudPlatform/google-cloud-python/issues - - -.. _Google Cloud SDK: https://cloud.google.com/sdk/ \ No newline at end of file diff --git a/samples/instanceadmin/README.rst.in b/samples/instanceadmin/README.rst.in deleted file mode 100644 index c085e40a6..000000000 --- a/samples/instanceadmin/README.rst.in +++ /dev/null @@ -1,23 +0,0 @@ -# This file is used to generate README.rst - -product: - name: Google Cloud Bigtable and run some basic operations. - short_name: Cloud Bigtable - url: https://cloud.google.com/bigtable/docs - description: > - `Google Cloud Bigtable`_ is Google's NoSQL Big Data database service. It's - the same database that powers many core Google services, including Search, - Analytics, Maps, and Gmail. - -setup: -- auth -- install_deps - -samples: -- name: Basic example with Bigtable Column family and GC rules. - file: instanceadmin.py - show_help: true - -cloud_client_library: true - -folder: bigtable/instanceadmin \ No newline at end of file diff --git a/samples/metricscaler/README.md b/samples/metricscaler/README.md new file mode 100644 index 000000000..d41a89a85 --- /dev/null +++ b/samples/metricscaler/README.md @@ -0,0 +1,52 @@ +[//]: # "This README.md file is auto-generated, all changes to this file will be lost." +[//]: # "To regenerate it, use `python -m synthtool`." + +## Python Samples for Cloud Bigtable + +This directory contains samples for Cloud Bigtable, which may be used as a refererence for how to use Cloud Bigtable. +Samples, quickstarts, and other documentation are available at cloud.google.com. + + +### Metric Scaler + +This sample demonstrates how to use Stackdriver Monitoring to scale Cloud Bigtable based on CPU usage. + + +Open in Cloud Shell + + +To run this sample: + +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]. + +1. Make a fork of this repo and clone the branch locally, then navigate to the sample directory you want to use. + +1. Install the dependencies needed to run the samples. + + pip install -r requirements.txt + +1. Run the sample using + + python metricscaler.py + + +
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
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


Scales Cloud Bigtable clusters based on CPU usage.


positional arguments:
  bigtable_instance     ID of the Cloud Bigtable instance to connect to.
  bigtable_cluster      ID of the Cloud Bigtable cluster to connect to.


optional arguments:
  -h, --help            show this help message and exit
  --high_cpu_threshold HIGH_CPU_THRESHOLD
                        If Cloud Bigtable CPU usage is above this threshold,
                        scale up
  --low_cpu_threshold LOW_CPU_THRESHOLD
                        If Cloud Bigtable CPU usage is below this threshold,
                        scale down
  --short_sleep SHORT_SLEEP
                        How long to sleep in seconds between checking metrics
                        after no scale operation
  --long_sleep LONG_SLEEP
                        How long to sleep in seconds between checking metrics
                        after a scaling operation
+ +## Additional Information + +You can read the documentation for more details on API usage and use GitHub +to [browse the source][source] and [report issues][issues]. + +### Contributing +For [contributing guidelines][contrib_guide], the [Python style guide][py_style], and more information on prerequisite steps to contribute, view the source code at googleapis/python-bigtable. + +[authentication]: https://cloud.google.com/docs/authentication/getting-started +[enable_billing]:https://cloud.google.com/apis/docs/getting-started#enabling_billing +[client_library_python]: https://googlecloudplatform.github.io/google-cloud-python/ +[source]: https://github.com/GoogleCloudPlatform/google-cloud-python +[issues]: https://github.com/GoogleCloudPlatform/google-cloud-python/issues +[contrib_guide]: https://github.com/googleapis/google-cloud-python/blob/master/CONTRIBUTING.rst +[py_style]: http://google.github.io/styleguide/pyguide.html +[cloud_sdk]: https://cloud.google.com/sdk/docs +[gcloud_shell]: https://cloud.google.com/shell/docs +[gcloud_shell]: https://cloud.google.com/shell/docs diff --git a/samples/metricscaler/README.rst b/samples/metricscaler/README.rst deleted file mode 100644 index c64bbff1d..000000000 --- a/samples/metricscaler/README.rst +++ /dev/null @@ -1,128 +0,0 @@ -.. This file is automatically generated. Do not edit this file directly. - -Google Cloud Bigtable Python Samples -=============================================================================== - -.. image:: https://gstatic.com/cloudssh/images/open-btn.png - :target: https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/GoogleCloudPlatform/python-docs-samples&page=editor&open_in_editor=bigtable/metricscaler/README.rst - - -This directory contains samples for Google Cloud Bigtable. `Google Cloud Bigtable`_ is Google's NoSQL Big Data database service. It's the same database that powers many core Google services, including Search, Analytics, Maps, and Gmail. - - -This sample demonstrates how to use `Stackdriver Monitoring`_ -to scale Cloud Bigtable based on CPU usage. - -.. _Stackdriver Monitoring: http://cloud.google.com/monitoring/docs/ - - -.. _Google Cloud Bigtable: https://cloud.google.com/bigtable/docs/ - -Setup -------------------------------------------------------------------------------- - - -Authentication -++++++++++++++ - -This sample requires you to have authentication setup. Refer to the -`Authentication Getting Started Guide`_ for instructions on setting up -credentials for applications. - -.. _Authentication Getting Started Guide: - https://cloud.google.com/docs/authentication/getting-started - -Install Dependencies -++++++++++++++++++++ - -#. Clone python-docs-samples and change directory to the sample directory you want to use. - - .. code-block:: bash - - $ git clone https://github.com/GoogleCloudPlatform/python-docs-samples.git - -#. Install `pip`_ and `virtualenv`_ if you do not already have them. You may want to refer to the `Python Development Environment Setup Guide`_ for Google Cloud Platform for instructions. - - .. _Python Development Environment Setup Guide: - https://cloud.google.com/python/setup - -#. Create a virtualenv. Samples are compatible with Python 2.7 and 3.4+. - - .. code-block:: bash - - $ virtualenv env - $ source env/bin/activate - -#. Install the dependencies needed to run the samples. - - .. code-block:: bash - - $ pip install -r requirements.txt - -.. _pip: https://pip.pypa.io/ -.. _virtualenv: https://virtualenv.pypa.io/ - -Samples -------------------------------------------------------------------------------- - -Metricscaling example -+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - -.. image:: https://gstatic.com/cloudssh/images/open-btn.png - :target: https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/GoogleCloudPlatform/python-docs-samples&page=editor&open_in_editor=bigtable/metricscaler/metricscaler.py,bigtable/metricscaler/README.rst - - - - -To run this sample: - -.. code-block:: bash - - $ python metricscaler.py - - 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 - - Scales Cloud Bigtable clusters based on CPU usage. - - positional arguments: - bigtable_instance ID of the Cloud Bigtable instance to connect to. - bigtable_cluster ID of the Cloud Bigtable cluster to connect to. - - optional arguments: - -h, --help show this help message and exit - --high_cpu_threshold HIGH_CPU_THRESHOLD - If Cloud Bigtable CPU usage is above this threshold, - scale up - --low_cpu_threshold LOW_CPU_THRESHOLD - If Cloud Bigtable CPU usage is below this threshold, - scale down - --short_sleep SHORT_SLEEP - How long to sleep in seconds between checking metrics - after no scale operation - --long_sleep LONG_SLEEP - How long to sleep in seconds between checking metrics - after a scaling operation - - - - - -The client library -------------------------------------------------------------------------------- - -This sample uses the `Google Cloud Client Library for Python`_. -You can read the documentation for more details on API usage and use GitHub -to `browse the source`_ and `report issues`_. - -.. _Google Cloud Client Library for Python: - https://googlecloudplatform.github.io/google-cloud-python/ -.. _browse the source: - https://github.com/GoogleCloudPlatform/google-cloud-python -.. _report issues: - https://github.com/GoogleCloudPlatform/google-cloud-python/issues - - -.. _Google Cloud SDK: https://cloud.google.com/sdk/ \ No newline at end of file diff --git a/samples/metricscaler/README.rst.in b/samples/metricscaler/README.rst.in deleted file mode 100644 index 44a548e4c..000000000 --- a/samples/metricscaler/README.rst.in +++ /dev/null @@ -1,29 +0,0 @@ -# This file is used to generate README.rst - -product: - name: Google Cloud Bigtable - short_name: Cloud Bigtable - url: https://cloud.google.com/bigtable/docs/ - description: > - `Google Cloud Bigtable`_ is Google's NoSQL Big Data database service. It's - the same database that powers many core Google services, including Search, - Analytics, Maps, and Gmail. - -description: | - This sample demonstrates how to use `Stackdriver Monitoring`_ - to scale Cloud Bigtable based on CPU usage. - - .. _Stackdriver Monitoring: http://cloud.google.com/monitoring/docs/ - -setup: -- auth -- install_deps - -samples: -- name: Metricscaling example - file: metricscaler.py - show_help: true - -cloud_client_library: true - -folder: bigtable/metricscaler \ No newline at end of file diff --git a/samples/quickstart/README.md b/samples/quickstart/README.md new file mode 100644 index 000000000..ae4f2e773 --- /dev/null +++ b/samples/quickstart/README.md @@ -0,0 +1,52 @@ +[//]: # "This README.md file is auto-generated, all changes to this file will be lost." +[//]: # "To regenerate it, use `python -m synthtool`." + +## Python Samples for Cloud Bigtable + +This directory contains samples for Cloud Bigtable, which may be used as a refererence for how to use Cloud Bigtable. +Samples, quickstarts, and other documentation are available at cloud.google.com. + + +### Quickstart + +Demonstrates of Cloud Bigtable. This sample creates a Bigtable client, connects to an instance and then to a table, then closes the connection. + + +Open in Cloud Shell + + +To run this sample: + +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]. + +1. Make a fork of this repo and clone the branch locally, then navigate to the sample directory you want to use. + +1. Install the dependencies needed to run the samples. + + pip install -r requirements.txt + +1. Run the sample using + + python main.py + + +
usage: main.py [-h] [--table TABLE] project_id instance_id
usage: main.py [-h] [--table TABLE] project_id instance_id


positional arguments:
  project_id     Your Cloud Platform project ID.
  instance_id    ID of the Cloud Bigtable instance to connect to.


optional arguments:
  -h, --help     show this help message and exit
  --table TABLE  Existing table used in the quickstart. (default: my-table)
+ +## Additional Information + +You can read the documentation for more details on API usage and use GitHub +to [browse the source][source] and [report issues][issues]. + +### Contributing +For [contributing guidelines][contrib_guide], the [Python style guide][py_style], and more information on prerequisite steps to contribute, view the source code at googleapis/python-bigtable. + +[authentication]: https://cloud.google.com/docs/authentication/getting-started +[enable_billing]:https://cloud.google.com/apis/docs/getting-started#enabling_billing +[client_library_python]: https://googlecloudplatform.github.io/google-cloud-python/ +[source]: https://github.com/GoogleCloudPlatform/google-cloud-python +[issues]: https://github.com/GoogleCloudPlatform/google-cloud-python/issues +[contrib_guide]: https://github.com/googleapis/google-cloud-python/blob/master/CONTRIBUTING.rst +[py_style]: http://google.github.io/styleguide/pyguide.html +[cloud_sdk]: https://cloud.google.com/sdk/docs +[gcloud_shell]: https://cloud.google.com/shell/docs +[gcloud_shell]: https://cloud.google.com/shell/docs diff --git a/samples/quickstart/README.rst b/samples/quickstart/README.rst deleted file mode 100644 index c3ff17a39..000000000 --- a/samples/quickstart/README.rst +++ /dev/null @@ -1,126 +0,0 @@ - -.. This file is automatically generated. Do not edit this file directly. - -Google Cloud Bigtable Python Samples -=============================================================================== - -.. image:: https://gstatic.com/cloudssh/images/open-btn.png - :target: https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/GoogleCloudPlatform/python-docs-samples&page=editor&open_in_editor=bigtable/quickstart/README.rst - - -This directory contains samples for Google Cloud Bigtable. `Google Cloud Bigtable`_ is Google's NoSQL Big Data database service. It's the same database that powers many core Google services, including Search, Analytics, Maps, and Gmail. - - - - -.. _Google Cloud Bigtable: https://cloud.google.com/bigtable/docs - - -Setup -------------------------------------------------------------------------------- - - - -Authentication -++++++++++++++ - -This sample requires you to have authentication setup. Refer to the -`Authentication Getting Started Guide`_ for instructions on setting up -credentials for applications. - -.. _Authentication Getting Started Guide: - https://cloud.google.com/docs/authentication/getting-started - - - - -Install Dependencies -++++++++++++++++++++ - -#. Clone python-docs-samples and change directory to the sample directory you want to use. - - .. code-block:: bash - - $ git clone https://github.com/GoogleCloudPlatform/python-docs-samples.git - -#. Install `pip`_ and `virtualenv`_ if you do not already have them. You may want to refer to the `Python Development Environment Setup Guide`_ for Google Cloud Platform for instructions. - - .. _Python Development Environment Setup Guide: - https://cloud.google.com/python/setup - -#. Create a virtualenv. Samples are compatible with Python 3.6+. - - .. code-block:: bash - - $ virtualenv env - $ source env/bin/activate - -#. Install the dependencies needed to run the samples. - - .. code-block:: bash - - $ pip install -r requirements.txt - -.. _pip: https://pip.pypa.io/ -.. _virtualenv: https://virtualenv.pypa.io/ - - - - - - -Samples -------------------------------------------------------------------------------- - - -Quickstart -+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - -.. image:: https://gstatic.com/cloudssh/images/open-btn.png - :target: https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/GoogleCloudPlatform/python-docs-samples&page=editor&open_in_editor=bigtable/quickstart/main.py,bigtable/quickstart/README.rst - - - - -To run this sample: - -.. code-block:: bash - - $ python main.py - - - usage: main.py [-h] [--table TABLE] project_id instance_id - - positional arguments: - project_id Your Cloud Platform project ID. - instance_id ID of the Cloud Bigtable instance to connect to. - - optional arguments: - -h, --help show this help message and exit - --table TABLE Existing table used in the quickstart. (default: my-table) - - - - - - - - - -The client library -------------------------------------------------------------------------------- - -This sample uses the `Google Cloud Client Library for Python`_. -You can read the documentation for more details on API usage and use GitHub -to `browse the source`_ and `report issues`_. - -.. _Google Cloud Client Library for Python: - https://googlecloudplatform.github.io/google-cloud-python/ -.. _browse the source: - https://github.com/GoogleCloudPlatform/google-cloud-python -.. _report issues: - https://github.com/GoogleCloudPlatform/google-cloud-python/issues - - - -.. _Google Cloud SDK: https://cloud.google.com/sdk/ diff --git a/samples/quickstart/README.rst.in b/samples/quickstart/README.rst.in deleted file mode 100644 index 94f070a7c..000000000 --- a/samples/quickstart/README.rst.in +++ /dev/null @@ -1,23 +0,0 @@ -# This file is used to generate README.rst - -product: - name: Google Cloud Bigtable - short_name: Cloud Bigtable - url: https://cloud.google.com/bigtable/docs - description: > - `Google Cloud Bigtable`_ is Google's NoSQL Big Data database service. It's - the same database that powers many core Google services, including Search, - Analytics, Maps, and Gmail. - -setup: -- auth -- install_deps - -samples: -- name: Quickstart - file: main.py - show_help: true - -cloud_client_library: true - -folder: bigtable/quickstart \ No newline at end of file diff --git a/samples/quickstart_happybase/README.md b/samples/quickstart_happybase/README.md new file mode 100644 index 000000000..edbd0bfcb --- /dev/null +++ b/samples/quickstart_happybase/README.md @@ -0,0 +1,52 @@ +[//]: # "This README.md file is auto-generated, all changes to this file will be lost." +[//]: # "To regenerate it, use `python -m synthtool`." + +## Python Samples for Cloud Bigtable + +This directory contains samples for Cloud Bigtable, which may be used as a refererence for how to use Cloud Bigtable. +Samples, quickstarts, and other documentation are available at cloud.google.com. + + +### Quickstart using HappyBase + +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. + + +Open in Cloud Shell + + +To run this sample: + +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]. + +1. Make a fork of this repo and clone the branch locally, then navigate to the sample directory you want to use. + +1. Install the dependencies needed to run the samples. + + pip install -r requirements.txt + +1. Run the sample using + + python main.py + + +
usage: main.py [-h] [--table TABLE] project_id instance_id
usage: main.py [-h] [--table TABLE] project_id instance_id


positional arguments:
  project_id     Your Cloud Platform project ID.
  instance_id    ID of the Cloud Bigtable instance to connect to.


optional arguments:
  -h, --help     show this help message and exit
  --table TABLE  Existing table used in the quickstart. (default: my-table)googleapis/python-bigtable. + +[authentication]: https://cloud.google.com/docs/authentication/getting-started +[enable_billing]:https://cloud.google.com/apis/docs/getting-started#enabling_billing +[client_library_python]: https://googlecloudplatform.github.io/google-cloud-python/ +[source]: https://github.com/GoogleCloudPlatform/google-cloud-python +[issues]: https://github.com/GoogleCloudPlatform/google-cloud-python/issues +[contrib_guide]: https://github.com/googleapis/google-cloud-python/blob/master/CONTRIBUTING.rst +[py_style]: http://google.github.io/styleguide/pyguide.html +[cloud_sdk]: https://cloud.google.com/sdk/docs +[gcloud_shell]: https://cloud.google.com/shell/docs +[gcloud_shell]: https://cloud.google.com/shell/docs diff --git a/samples/quickstart_happybase/README.rst b/samples/quickstart_happybase/README.rst deleted file mode 100644 index e2d1c45a2..000000000 --- a/samples/quickstart_happybase/README.rst +++ /dev/null @@ -1,108 +0,0 @@ -.. This file is automatically generated. Do not edit this file directly. - -Google Cloud Bigtable Python Samples -=============================================================================== - -.. image:: https://gstatic.com/cloudssh/images/open-btn.png - :target: https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/GoogleCloudPlatform/python-docs-samples&page=editor&open_in_editor=bigtable/quickstart_happybase/README.rst - - -This directory contains samples for Google Cloud Bigtable. `Google Cloud Bigtable`_ is Google's NoSQL Big Data database service. It's the same database that powers many core Google services, including Search, Analytics, Maps, and Gmail. - - - - -.. _Google Cloud Bigtable: https://cloud.google.com/bigtable/docs - -Setup -------------------------------------------------------------------------------- - - -Authentication -++++++++++++++ - -This sample requires you to have authentication setup. Refer to the -`Authentication Getting Started Guide`_ for instructions on setting up -credentials for applications. - -.. _Authentication Getting Started Guide: - https://cloud.google.com/docs/authentication/getting-started - -Install Dependencies -++++++++++++++++++++ - -#. Clone python-docs-samples and change directory to the sample directory you want to use. - - .. code-block:: bash - - $ git clone https://github.com/GoogleCloudPlatform/python-docs-samples.git - -#. Install `pip`_ and `virtualenv`_ if you do not already have them. You may want to refer to the `Python Development Environment Setup Guide`_ for Google Cloud Platform for instructions. - - .. _Python Development Environment Setup Guide: - https://cloud.google.com/python/setup - -#. Create a virtualenv. Samples are compatible with Python 2.7 and 3.4+. - - .. code-block:: bash - - $ virtualenv env - $ source env/bin/activate - -#. Install the dependencies needed to run the samples. - - .. code-block:: bash - - $ pip install -r requirements.txt - -.. _pip: https://pip.pypa.io/ -.. _virtualenv: https://virtualenv.pypa.io/ - -Samples -------------------------------------------------------------------------------- - -Quickstart -+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - -.. image:: https://gstatic.com/cloudssh/images/open-btn.png - :target: https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/GoogleCloudPlatform/python-docs-samples&page=editor&open_in_editor=bigtable/quickstart_happybase/main.py,bigtable/quickstart_happybase/README.rst - - - - -To run this sample: - -.. code-block:: bash - - $ python main.py - - usage: main.py [-h] [--table TABLE] project_id instance_id - - positional arguments: - project_id Your Cloud Platform project ID. - instance_id ID of the Cloud Bigtable instance to connect to. - - optional arguments: - -h, --help show this help message and exit - --table TABLE Existing table used in the quickstart. (default: my-table) - - - - - -The client library -------------------------------------------------------------------------------- - -This sample uses the `Google Cloud Client Library for Python`_. -You can read the documentation for more details on API usage and use GitHub -to `browse the source`_ and `report issues`_. - -.. _Google Cloud Client Library for Python: - https://googlecloudplatform.github.io/google-cloud-python/ -.. _browse the source: - https://github.com/GoogleCloudPlatform/google-cloud-python -.. _report issues: - https://github.com/GoogleCloudPlatform/google-cloud-python/issues - - -.. _Google Cloud SDK: https://cloud.google.com/sdk/ \ No newline at end of file diff --git a/samples/quickstart_happybase/README.rst.in b/samples/quickstart_happybase/README.rst.in deleted file mode 100644 index 811a0b868..000000000 --- a/samples/quickstart_happybase/README.rst.in +++ /dev/null @@ -1,23 +0,0 @@ -# This file is used to generate README.rst - -product: - name: Google Cloud Bigtable - short_name: Cloud Bigtable - url: https://cloud.google.com/bigtable/docs - description: > - `Google Cloud Bigtable`_ is Google's NoSQL Big Data database service. It's - the same database that powers many core Google services, including Search, - Analytics, Maps, and Gmail. - -setup: -- auth -- install_deps - -samples: -- name: Quickstart - file: main.py - show_help: true - -cloud_client_library: true - -folder: bigtable/quickstart_happybase \ No newline at end of file diff --git a/samples/snippets/README.md b/samples/snippets/README.md new file mode 100644 index 000000000..0d6f32edb --- /dev/null +++ b/samples/snippets/README.md @@ -0,0 +1,33 @@ +[//]: # "This README.md file is auto-generated, all changes to this file will be lost." +[//]: # "To regenerate it, use `python -m synthtool`." + +## Python Samples for Cloud Bigtable + +This directory contains samples for Cloud Bigtable, which may be used as a refererence for how to use Cloud Bigtable. +Samples, quickstarts, and other documentation are available at cloud.google.com. + + +### Snippets + +This folder contains snippets for Python Cloud Bigtable. + + + +## Additional Information + +You can read the documentation for more details on API usage and use GitHub +to [browse the source][source] and [report issues][issues]. + +### Contributing +For [contributing guidelines][contrib_guide], the [Python style guide][py_style], and more information on prerequisite steps to contribute, view the source code at googleapis/python-bigtable. + +[authentication]: https://cloud.google.com/docs/authentication/getting-started +[enable_billing]:https://cloud.google.com/apis/docs/getting-started#enabling_billing +[client_library_python]: https://googlecloudplatform.github.io/google-cloud-python/ +[source]: https://github.com/GoogleCloudPlatform/google-cloud-python +[issues]: https://github.com/GoogleCloudPlatform/google-cloud-python/issues +[contrib_guide]: https://github.com/googleapis/google-cloud-python/blob/master/CONTRIBUTING.rst +[py_style]: http://google.github.io/styleguide/pyguide.html +[cloud_sdk]: https://cloud.google.com/sdk/docs +[gcloud_shell]: https://cloud.google.com/shell/docs +[gcloud_shell]: https://cloud.google.com/shell/docs diff --git a/samples/tableadmin/README.md b/samples/tableadmin/README.md new file mode 100644 index 000000000..d3aa038a4 --- /dev/null +++ b/samples/tableadmin/README.md @@ -0,0 +1,52 @@ +[//]: # "This README.md file is auto-generated, all changes to this file will be lost." +[//]: # "To regenerate it, use `python -m synthtool`." + +## Python Samples for Cloud Bigtable + +This directory contains samples for Cloud Bigtable, which may be used as a refererence for how to use Cloud Bigtable. +Samples, quickstarts, and other documentation are available at cloud.google.com. + + +### Table Admin + +Demonstrates how to connect to Cloud Bigtable and run some basic operations. + + +Open in Cloud Shell + + +To run this sample: + +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]. + +1. Make a fork of this repo and clone the branch locally, then navigate to the sample directory you want to use. + +1. Install the dependencies needed to run the samples. + + pip install -r requirements.txt + +1. Run the sample using + + python tableadmin.py + + +
usage: tableadmin.py [-h] [run] [delete] [--table TABLE] project_id instance_id
usage: tableadmin.py [-h] [run] [delete] [--table TABLE] project_id instance_id


Demonstrates how to connect to Cloud Bigtable and run some basic operations.
Prerequisites: - Create a Cloud Bigtable cluster.
https://cloud.google.com/bigtable/docs/creating-cluster - Set your Google
Application Default Credentials.
https://developers.google.com/identity/protocols/application-default-
credentials


positional arguments:
  project_id     Your Cloud Platform project ID.
  instance_id    ID of the Cloud Bigtable instance to connect to.


optional arguments:
  -h, --help     show this help message and exit
  --table TABLE  Table to create and destroy. (default: Hello-Bigtable)
+ +## Additional Information + +You can read the documentation for more details on API usage and use GitHub +to [browse the source][source] and [report issues][issues]. + +### Contributing +For [contributing guidelines][contrib_guide], the [Python style guide][py_style], and more information on prerequisite steps to contribute, view the source code at googleapis/python-bigtable. + +[authentication]: https://cloud.google.com/docs/authentication/getting-started +[enable_billing]:https://cloud.google.com/apis/docs/getting-started#enabling_billing +[client_library_python]: https://googlecloudplatform.github.io/google-cloud-python/ +[source]: https://github.com/GoogleCloudPlatform/google-cloud-python +[issues]: https://github.com/GoogleCloudPlatform/google-cloud-python/issues +[contrib_guide]: https://github.com/googleapis/google-cloud-python/blob/master/CONTRIBUTING.rst +[py_style]: http://google.github.io/styleguide/pyguide.html +[cloud_sdk]: https://cloud.google.com/sdk/docs +[gcloud_shell]: https://cloud.google.com/shell/docs +[gcloud_shell]: https://cloud.google.com/shell/docs diff --git a/samples/tableadmin/README.rst b/samples/tableadmin/README.rst deleted file mode 100644 index f7f83d6d2..000000000 --- a/samples/tableadmin/README.rst +++ /dev/null @@ -1,115 +0,0 @@ -.. This file is automatically generated. Do not edit this file directly. - -Google Cloud Bigtable Python Samples -=============================================================================== - -.. image:: https://gstatic.com/cloudssh/images/open-btn.png - :target: https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/GoogleCloudPlatform/python-docs-samples&page=editor&open_in_editor=bigtable/hello/README.rst - - -This directory contains samples for Google Cloud Bigtable. `Google Cloud Bigtable`_ is Google's NoSQL Big Data database service. It's the same database that powers many core Google services, including Search, Analytics, Maps, and Gmail. - - - - -.. _Google Cloud Bigtable: https://cloud.google.com/bigtable/docs - -Setup -------------------------------------------------------------------------------- - - -Authentication -++++++++++++++ - -This sample requires you to have authentication setup. Refer to the -`Authentication Getting Started Guide`_ for instructions on setting up -credentials for applications. - -.. _Authentication Getting Started Guide: - https://cloud.google.com/docs/authentication/getting-started - -Install Dependencies -++++++++++++++++++++ - -#. Clone python-docs-samples and change directory to the sample directory you want to use. - - .. code-block:: bash - - $ git clone https://github.com/GoogleCloudPlatform/python-docs-samples.git - -#. Install `pip`_ and `virtualenv`_ if you do not already have them. You may want to refer to the `Python Development Environment Setup Guide`_ for Google Cloud Platform for instructions. - - .. _Python Development Environment Setup Guide: - https://cloud.google.com/python/setup - -#. Create a virtualenv. Samples are compatible with Python 2.7 and 3.4+. - - .. code-block:: bash - - $ virtualenv env - $ source env/bin/activate - -#. Install the dependencies needed to run the samples. - - .. code-block:: bash - - $ pip install -r requirements.txt - -.. _pip: https://pip.pypa.io/ -.. _virtualenv: https://virtualenv.pypa.io/ - -Samples -------------------------------------------------------------------------------- - -Basic example -+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - -.. image:: https://gstatic.com/cloudssh/images/open-btn.png - :target: https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/GoogleCloudPlatform/python-docs-samples&page=editor&open_in_editor=bigtable/hello/tableadmin.py,bigtable/hello/README.rst - - - - -To run this sample: - -.. code-block:: bash - - $ python tableadmin.py - - usage: tableadmin.py [-h] [run] [delete] [--table TABLE] project_id instance_id - - Demonstrates how to connect to Cloud Bigtable and run some basic operations. - Prerequisites: - Create a Cloud Bigtable cluster. - https://cloud.google.com/bigtable/docs/creating-cluster - Set your Google - Application Default Credentials. - https://developers.google.com/identity/protocols/application-default- - credentials - - positional arguments: - project_id Your Cloud Platform project ID. - instance_id ID of the Cloud Bigtable instance to connect to. - - optional arguments: - -h, --help show this help message and exit - --table TABLE Table to create and destroy. (default: Hello-Bigtable) - - - - - -The client library -------------------------------------------------------------------------------- - -This sample uses the `Google Cloud Client Library for Python`_. -You can read the documentation for more details on API usage and use GitHub -to `browse the source`_ and `report issues`_. - -.. _Google Cloud Client Library for Python: - https://googlecloudplatform.github.io/google-cloud-python/ -.. _browse the source: - https://github.com/GoogleCloudPlatform/google-cloud-python -.. _report issues: - https://github.com/GoogleCloudPlatform/google-cloud-python/issues - - -.. _Google Cloud SDK: https://cloud.google.com/sdk/ \ No newline at end of file diff --git a/samples/tableadmin/README.rst.in b/samples/tableadmin/README.rst.in deleted file mode 100644 index 7fd376419..000000000 --- a/samples/tableadmin/README.rst.in +++ /dev/null @@ -1,23 +0,0 @@ -# This file is used to generate README.rst - -product: - name: Google Cloud Bigtable and run some basic operations. - short_name: Cloud Bigtable - url: https://cloud.google.com/bigtable/docs - description: > - `Google Cloud Bigtable`_ is Google's NoSQL Big Data database service. It's - the same database that powers many core Google services, including Search, - Analytics, Maps, and Gmail. - -setup: -- auth -- install_deps - -samples: -- name: Basic example with Bigtable Column family and GC rules. - file: tableadmin.py - show_help: true - -cloud_client_library: true - -folder: bigtable/tableadmin \ No newline at end of file diff --git a/synth.py b/synth.py index 141d93dd3..8a2fed1c7 100644 --- a/synth.py +++ b/synth.py @@ -91,6 +91,9 @@ # Samples templates # ---------------------------------------------------------------------------- -python.py_samples(skip_readmes=True) +sample_files = common.py_samples(samples=True) +for path in sample_files: + s.move(path, excludes=['noxfile.py']) + s.shell.run(["nox", "-s", "blacken"], hide_output=False)