Skip to content

Commit 7bd7382

Browse files
authored
fix: typos and errors in quickstart programs (#8249)
1 parent 88972d0 commit 7bd7382

10 files changed

Lines changed: 30 additions & 24 deletions

File tree

google/cloud/gkehub/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ this library.
4545
#include <stdexcept>
4646

4747
int main(int argc, char* argv[]) try {
48-
if (argc != 2) {
48+
if (argc != 3) {
4949
std::cerr << "Usage: " << argv[0] << " project-id location-id\n";
5050
return 1;
5151
}
@@ -54,7 +54,7 @@ int main(int argc, char* argv[]) try {
5454
auto client = gkehub::GkeHubClient(gkehub::MakeGkeHubConnection());
5555

5656
auto const location =
57-
"projects/" + std::string(argv[0]) + "/locations/" + std::string(argv[1]);
57+
std::string{"projects/"} + argv[1] + "/locations/" + argv[2];
5858
for (auto r : client.ListMemberships(location)) {
5959
if (!r) throw std::runtime_error(r.status().message());
6060
std::cout << r->DebugString() << "\n";

google/cloud/gkehub/quickstart/quickstart.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
#include <stdexcept>
1818

1919
int main(int argc, char* argv[]) try {
20-
if (argc != 2) {
20+
if (argc != 3) {
2121
std::cerr << "Usage: " << argv[0] << " project-id location-id\n";
2222
return 1;
2323
}
@@ -26,7 +26,7 @@ int main(int argc, char* argv[]) try {
2626
auto client = gkehub::GkeHubClient(gkehub::MakeGkeHubConnection());
2727

2828
auto const location =
29-
"projects/" + std::string(argv[0]) + "/locations/" + std::string(argv[1]);
29+
std::string{"projects/"} + argv[1] + "/locations/" + argv[2];
3030
for (auto r : client.ListMemberships(location)) {
3131
if (!r) throw std::runtime_error(r.status().message());
3232
std::cout << r->DebugString() << "\n";

google/cloud/kms/README.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,17 +46,18 @@ this library.
4646
#include <stdexcept>
4747

4848
int main(int argc, char* argv[]) try {
49-
if (argc != 2) {
50-
std::cerr << "Usage: " << argv[0] << " project-id\n";
49+
if (argc != 3) {
50+
std::cerr << "Usage: " << argv[0] << " project-id location-id\n";
5151
return 1;
5252
}
5353

5454
namespace kms = ::google::cloud::kms;
5555
auto client = kms::KeyManagementServiceClient(
5656
kms::MakeKeyManagementServiceConnection());
57-
auto const project = google::cloud::Project(argv[1]);
5857

59-
for (auto r : client.ListKeyRings(project.FullName())) {
58+
auto const parent =
59+
std::string{"projects/"} + argv[1] + "/locations/" + argv[2];
60+
for (auto r : client.ListKeyRings(parent)) {
6061
if (!r) throw std::runtime_error(r.status().message());
6162
std::cout << r->DebugString() << "\n";
6263
}

google/cloud/kms/quickstart/quickstart.cc

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,17 +18,18 @@
1818
#include <stdexcept>
1919

2020
int main(int argc, char* argv[]) try {
21-
if (argc != 2) {
22-
std::cerr << "Usage: " << argv[0] << " project-id\n";
21+
if (argc != 3) {
22+
std::cerr << "Usage: " << argv[0] << " project-id location-id\n";
2323
return 1;
2424
}
2525

2626
namespace kms = ::google::cloud::kms;
2727
auto client = kms::KeyManagementServiceClient(
2828
kms::MakeKeyManagementServiceConnection());
29-
auto const project = google::cloud::Project(argv[1]);
3029

31-
for (auto r : client.ListKeyRings(project.FullName())) {
30+
auto const parent =
31+
std::string{"projects/"} + argv[1] + "/locations/" + argv[2];
32+
for (auto r : client.ListKeyRings(parent)) {
3233
if (!r) throw std::runtime_error(r.status().message());
3334
std::cout << r->DebugString() << "\n";
3435
}

google/cloud/logging/README.md

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,21 +43,23 @@ this library.
4343
<!-- inject-quickstart-start -->
4444
```cc
4545
#include "google/cloud/logging/logging_service_v2_client.h"
46+
#include "google/cloud/project.h"
4647
#include <iostream>
4748
#include <stdexcept>
4849

4950
int main(int argc, char* argv[]) try {
50-
if (argc != 4) {
51+
if (argc != 2) {
5152
std::cerr << "Usage: " << argv[0] << " project-id\n";
5253
return 1;
5354
}
5455

5556
namespace logging = ::google::cloud::logging;
5657
auto client = logging::LoggingServiceV2Client(
5758
logging::MakeLoggingServiceV2Connection());
58-
auto const parent = std::string("projects/") + argv[1];
59-
for (auto const& logs : client.ListLogs(parent)) {
60-
std::cout << logs.value() << "\n";
59+
auto const project = google::cloud::Project(argv[1]);
60+
for (auto l : client.ListLogs(project.FullName())) {
61+
if (!l) throw std::runtime_error(l.status().message());
62+
std::cout << *l << "\n";
6163
}
6264

6365
return 0;

google/cloud/logging/quickstart/quickstart.cc

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,21 +13,23 @@
1313
// limitations under the License.
1414

1515
#include "google/cloud/logging/logging_service_v2_client.h"
16+
#include "google/cloud/project.h"
1617
#include <iostream>
1718
#include <stdexcept>
1819

1920
int main(int argc, char* argv[]) try {
20-
if (argc != 4) {
21+
if (argc != 2) {
2122
std::cerr << "Usage: " << argv[0] << " project-id\n";
2223
return 1;
2324
}
2425

2526
namespace logging = ::google::cloud::logging;
2627
auto client = logging::LoggingServiceV2Client(
2728
logging::MakeLoggingServiceV2Connection());
28-
auto const parent = std::string("projects/") + argv[1];
29-
for (auto const& logs : client.ListLogs(parent)) {
30-
std::cout << logs.value() << "\n";
29+
auto const project = google::cloud::Project(argv[1]);
30+
for (auto l : client.ListLogs(project.FullName())) {
31+
if (!l) throw std::runtime_error(l.status().message());
32+
std::cout << *l << "\n";
3133
}
3234

3335
return 0;

google/cloud/memcache/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ int main(int argc, char* argv[]) try {
5555
memcache::CloudMemcacheClient(memcache::MakeCloudMemcacheConnection());
5656

5757
auto const project_id = std::string(argv[1]);
58-
auto const parent = "projects/" + project_id + "locations/-";
58+
auto const parent = "projects/" + project_id + "/locations/-";
5959
for (auto r : client.ListInstances(parent)) {
6060
if (!r) throw std::runtime_error(r.status().message());
6161
std::cout << r->DebugString() << "\n";

google/cloud/memcache/quickstart/quickstart.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ int main(int argc, char* argv[]) try {
2828
memcache::CloudMemcacheClient(memcache::MakeCloudMemcacheConnection());
2929

3030
auto const project_id = std::string(argv[1]);
31-
auto const parent = "projects/" + project_id + "locations/-";
31+
auto const parent = "projects/" + project_id + "/locations/-";
3232
for (auto r : client.ListInstances(parent)) {
3333
if (!r) throw std::runtime_error(r.status().message());
3434
std::cout << r->DebugString() << "\n";

google/cloud/redis/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ int main(int argc, char* argv[]) try {
5454
auto client = redis::CloudRedisClient(redis::MakeCloudRedisConnection());
5555

5656
auto const project_id = std::string(argv[1]);
57-
auto const parent = "projects/" + project_id + "locations/-";
57+
auto const parent = "projects/" + project_id + "/locations/-";
5858
for (auto r : client.ListInstances(parent)) {
5959
if (!r) throw std::runtime_error(r.status().message());
6060
std::cout << r->DebugString() << "\n";

google/cloud/redis/quickstart/quickstart.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ int main(int argc, char* argv[]) try {
2727
auto client = redis::CloudRedisClient(redis::MakeCloudRedisConnection());
2828

2929
auto const project_id = std::string(argv[1]);
30-
auto const parent = "projects/" + project_id + "locations/-";
30+
auto const parent = "projects/" + project_id + "/locations/-";
3131
for (auto r : client.ListInstances(parent)) {
3232
if (!r) throw std::runtime_error(r.status().message());
3333
std::cout << r->DebugString() << "\n";

0 commit comments

Comments
 (0)