Skip to content

Commit 55df15b

Browse files
authored
feat(bigtable): accept optional app profile ID in quickstart (googleapis#16091)
1 parent 3852865 commit 55df15b

3 files changed

Lines changed: 20 additions & 12 deletions

File tree

google/cloud/bigtable/README.md

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,23 +21,26 @@ this library.
2121
#include "google/cloud/bigtable/table.h"
2222

2323
int main(int argc, char* argv[]) try {
24-
if (argc != 4) {
24+
if (argc != 4 && argc != 5) {
2525
std::string const cmd = argv[0];
2626
auto last_slash = std::string(cmd).find_last_of('/');
2727
std::cerr << "Usage: " << cmd.substr(last_slash + 1)
28-
<< " <project_id> <instance_id> <table_id>\n";
28+
<< " <project_id> <instance_id> <table_id> [app_profile_id]\n";
2929
return 1;
3030
}
3131

3232
std::string const project_id = argv[1];
3333
std::string const instance_id = argv[2];
3434
std::string const table_id = argv[3];
35+
std::string const app_profile_id = (argc == 5 ? argv[4] : "default");
3536

3637
// Create a namespace alias to make the code easier to read.
3738
namespace cbt = ::google::cloud::bigtable;
3839

39-
cbt::Table table(cbt::MakeDataConnection(),
40-
cbt::TableResource(project_id, instance_id, table_id));
40+
cbt::Table table(
41+
cbt::MakeDataConnection(),
42+
cbt::TableResource(project_id, instance_id, table_id),
43+
google::cloud::Options{}.set<cbt::AppProfileIdOption>(app_profile_id));
4144

4245
std::string row_key = "r1";
4346
std::string column_family = "cf1";

google/cloud/bigtable/quickstart/README.md

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,11 @@ review the [Authentication methods at Google][authentication-quickstart].
5555
project. As it is often the case with C++ libraries, compiling these
5656
dependencies may take several minutes.
5757

58-
1. Run the example, changing the placeholder(s) to appropriate values:
58+
1. Run the example, changing the placeholder(s) to appropriate values (the app
59+
profile ID is optional):
5960

6061
```bash
61-
bazel run :quickstart -- [GCP PROJECT] [CLOUD BIGTABLE INSTANCE] [CLOUD BIGTABLE TABLE]
62+
bazel run :quickstart -- [GCP PROJECT] [CLOUD BIGTABLE INSTANCE] [CLOUD BIGTABLE TABLE] [[APP PROFILE ID]]
6263
```
6364

6465
## Using with CMake
@@ -92,10 +93,11 @@ review the [Authentication methods at Google][authentication-quickstart].
9293
cmake --build .build
9394
```
9495

95-
1. Run the example, changing the placeholder(s) to appropriate values:
96+
1. Run the example, changing the placeholder(s) to appropriate values (the app
97+
profile ID is optional):
9698

9799
```bash
98-
.build/quickstart [GCP PROJECT] [CLOUD BIGTABLE INSTANCE] [CLOUD BIGTABLE TABLE]
100+
.build/quickstart [GCP PROJECT] [CLOUD BIGTABLE INSTANCE] [CLOUD BIGTABLE TABLE] [[APP PROFILE ID]]
99101
```
100102

101103
## Platform Specific Notes

google/cloud/bigtable/quickstart/quickstart.cc

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,23 +16,26 @@
1616
#include "google/cloud/bigtable/table.h"
1717

1818
int main(int argc, char* argv[]) try {
19-
if (argc != 4) {
19+
if (argc != 4 && argc != 5) {
2020
std::string const cmd = argv[0];
2121
auto last_slash = std::string(cmd).find_last_of('/');
2222
std::cerr << "Usage: " << cmd.substr(last_slash + 1)
23-
<< " <project_id> <instance_id> <table_id>\n";
23+
<< " <project_id> <instance_id> <table_id> [app_profile_id]\n";
2424
return 1;
2525
}
2626

2727
std::string const project_id = argv[1];
2828
std::string const instance_id = argv[2];
2929
std::string const table_id = argv[3];
30+
std::string const app_profile_id = (argc == 5 ? argv[4] : "default");
3031

3132
// Create a namespace alias to make the code easier to read.
3233
namespace cbt = ::google::cloud::bigtable;
3334

34-
cbt::Table table(cbt::MakeDataConnection(),
35-
cbt::TableResource(project_id, instance_id, table_id));
35+
cbt::Table table(
36+
cbt::MakeDataConnection(),
37+
cbt::TableResource(project_id, instance_id, table_id),
38+
google::cloud::Options{}.set<cbt::AppProfileIdOption>(app_profile_id));
3639

3740
std::string row_key = "r1";
3841
std::string column_family = "cf1";

0 commit comments

Comments
 (0)