These samples demonstrate how to call the Google Cloud Bigtable API using C++.
-
Create a project in the Google Cloud Console. If you haven't already created a project, create one now. Projects enable you to manage all Google Cloud Platform resources for your app, including deployment, access control, billing, and services.
- Open the Google Cloud Console.
- In the drop-down menu at the top, select Create a project.
- Click Show advanced options. Under App Engine location, select a United States location.
- Give your project a name.
- Make a note of the project ID, which might be different from the project name. The project ID is used in commands and in configurations.
-
Enable billing for your project. If you haven't already enabled billing for your project, enable billing now. Enabling billing allows the application to consume billable resources such as Cloud Bigtable API calls. See Google Cloud Console Help for more information about billing settings.
-
Enable the Cloud Bigtable Admin APIs for your project. Click here to visit Google Cloud Console and enable the Bigtable Admin API.
-
Enable the Cloud Bigtable APIs for your project. Click here to visit Google Cloud Console and enable the Bigtable Admin API.
-
Download service account credentials. These samples use service accounts for authentication.
- Visit the Google Cloud Console, and navigate to:
API Manager > Credentials > Create credentials > Service account key - Under Service account, select
New service account. - Under Service account name, enter a service account name of your choosing. For example,
transcriber. - Under Role, select
Project > Service Account Actor. - Under Key type, leave
JSONselected. - Click Create to create a new service account, and download the json credentials file.
- Set the
GOOGLE_APPLICATION_CREDENTIALSenvironment variable to point to your downloaded service account credentials:export GOOGLE_APPLICATION_CREDENTIALS=/path/to/your/credentials-key.json
See the Cloud Platform Auth Guide for more information.
- Visit the Google Cloud Console, and navigate to:
-
Install gRPC.
- Visit the gRPC github repo and follow the instructions to install gRPC.
- Then, follow the instructions in the Pre-requisites section to install protoc.
-
Download or close this repo with
git clone https://github.com/GoogleCloudPlatform/cpp-docs-samples cd cpp-docs-samples git submodule update --init
-
Generate googleapis gRPC source code.
cd bigtable/api env -u LANGUAGE make -C googleapis OUTPUT=$PWD/googleapis-gens
-
Compile the examples
cmake . make -j 2
-
Run the examples
# This should be the name of the project you enabled billing and the APIs for. PROJECT=<your project here> # ... outside GCE you may need to set: # export GOOGLE_APPLICATION_CREDENTIALS=<path to service account private key file> ./list_instances $PROJECT ./create_instance $PROJECT bt-test-instance cluster-00 us-east1-c ./list_instances $PROJECT ./create_table $PROJECT bt-test-instance my-table ./list_tables $PROJECT bt-test-instance ./delete_table $PROJECT bt-test-instance my-table ./create_table $PROJECT bt-test-instance daily ./create_table $PROJECT bt-test-instance quote-per-row ./resources/download_taq.sh ./upload_taq $PROJECT bt-test-instance quote-per-row NBBO.txt ./upload_taq_batch $PROJECT bt-test-instance quote-per-row 20161024 NBBO.txt ./read_row $PROJECT bt-test-instance quote-per-row 20161024 ./delete_instance $PROJECT bt-test-instance ./list_instances $PROJECT